7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » How are Image Gallery files renamed on upload?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 892 Views |
-
How are Image Gallery files renamed on upload?

23 June 2010 at 8:53am Last edited: 23 June 2010 8:55am
I'm trying to figure out exactly how files are renamed when you upload them into an Image Gallery album. Spaces are replaced with hyphens, multiple hyphens are cleaned up, underscores are (sometimes) removed, and punctuation is removed. There might be other stuff going on too, but I'm not sure because I haven't been able to track down the exact functions responsible.
I need to be able to associate the original file name with the one that SilverStripe created on upload, so I really need to know exactly what's going on. Anybody have any ideas where to look? I thought I might have found it in sapphire/filesystem/File.php, function setName($name), but after trying it on some sample input, it seems that's not quite it.
-
Re: How are Image Gallery files renamed on upload?

23 June 2010 at 9:11am
I think it uses the same algorithm as SiteTree:generateURLSegment().. [a-zA-Z0-9\-], with spaces replaced with hyphens.
-
Re: How are Image Gallery files renamed on upload?

24 June 2010 at 4:23am
That wasn't quite it either. After some digging, I think I found it inside the load() function in sapphire/filesystem/Upload.php, starting on line 114:
// Generate default filename
$fileName = str_replace(' ', '-',$tmpFile['name']);
$fileName = ereg_replace('[^A-Za-z0-9+.-]+','',$fileName);
$fileName = ereg_replace('-+', '-',$fileName);
$fileName = basename($fileName);
| 892 Views | ||
|
Page:
1
|
Go to Top |

