Remove first 3 digits in img title. I have the code to do so

Phoca Gallery - image gallery extension
siddan
Phoca Member
Phoca Member
Posts: 40
Joined: 08 Aug 2009, 16:37

Remove first 3 digits in img title. I have the code to do so

Post by siddan »

Hello

This is just a small thing to improve image sorting, for me at least....
I have all my image file names beginning with 001 firstpic.jpg, 002 secondpic, 003 thirdpic etc. This way I can have total control of sorting my images and then have a good overview of the order when uploading them to phoca.

I have a useful php snippet which will remove the first 3 digits , if there are any.
Allthough I have used this on the title name below the thumbnail and in the Highslide JS image header, I came to realize that I must have this php snippet pasted just before all output generated titles. And that would be quite a few.

So instead I try the luck in asking where I can paste this php snippet in one place so it applies on all $value->title variables?

This is the snippet in question

Code: Select all

// Remove first 3 digits of title name, if any
		$value->title = preg_replace(
		   array('/^[0-9]{1,3}/', '/_/'),
		   array('', ' '), $value->title
		);
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Remove first 3 digits in img title. I have the code to d

Post by Jan »

Hi, thank you for this info.

Jan
If you find Phoca extensions useful, please support the project
Post Reply