Topic: buildgallery.php -> Replace underscore with space

Hi!

Is there a possibility to replace an underscore with a space? I don´t like to do this manually everytime... For example the name of the picture is "Example_2012.jpg".
So I want to rename the caption ("Add caption" in buildgallery options) to "Example 2012"

You know what I mean?

Re: buildgallery.php -> Replace underscore with space

To replace underscores with spaces when using the filenames as captions, add the following code on line 464 of the 'buildgallery.php' file (immediately before the $imageObjects[$key]->setCaption($caption, OK_CAPTION_TAGS); line):

$caption = str_replace('_', ' ', $caption);

Please note that the line number above refers to 'buildgallery.php' v2.1.1.

Steven Speirs
SimpleViewer Support Team.

Re: buildgallery.php -> Replace underscore with space

Perfect, it works! Thank you!
How can I delete the Number at the end? "Example_2012:1.jpg" -> Caption:"Example 2012"?
So I would like to delete everything behind the underscore and the underscore itself.

Thank you!

Re: buildgallery.php -> Replace underscore with space

So I would like to delete everything behind the underscore and the underscore itself.

Use the following code instead of the line posted above which will remove the first underscore in the string and everything after it.

$caption = substr($caption, 0, strpos($caption, '_'));
Steven Speirs
SimpleViewer Support Team.

Re: buildgallery.php -> Replace underscore with space

Hmmmm... I tried it, but it didn´t work.
Should I really replace the first command through the second one?
I want to delete the underscores AND every number after the ":". Sorry if i wrote it wrong. I´m a littel bit confused  roll

Re: buildgallery.php -> Replace underscore with space

Try adding the following code on line 464 of the 'buildgallery.php' file (immediately before the $imageObjects[$key]->setCaption($caption, OK_CAPTION_TAGS); line):

$caption = str_replace('_', ' ', $caption);
$caption = substr($caption, 0, strpos($caption, ':'));

This will first remove all underscores from the caption and will then remove the first colon in the string and everything after it, transforming a caption such as 'Example_2012:1.jpg' into 'Example 2012'.

Steven Speirs
SimpleViewer Support Team.