21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1359 Views |
-
Expanding the Specialized File Type List

25 March 2009 at 9:30am Last edited: 25 March 2009 9:32am
SilverStripe’s “Files & Images†gives images special treatment. When uploaded, they are identified in the database (in the File table) as being of class Image. This information is later used by the system in various ways, including allowing SetWidth and SetHeight to be called from template code on images even though those methods are not available on other file types.
Recently, I encountered a situation where it was necessary to give PDF files special behavior. It was easy to create a class PDF (child of class File) where I could add the desired methods. However, in order to get the uploader code to realize that .pdf files should be marked as class PDF in table File, I needed to edit the core file sapphire/filesystem/Folder.php. Needless to say, it is undesirable to edit core files to make configuration changes like registering a file type.
The thought came to adjust Folder.php so that it maintains an array of file extensions and associated class names (like array(‘PDF’=> array(‘pdf’), ‘Image’ => array(‘jpg’, ‘jpeg’, ‘gif’, ‘png)) which would be used to identify the appropriate class with which to tag newly uploaded files. File type registration would be done in _config.php files using a syntax something like: File::register_type('pdf', 'PDF').
Does this should like a feature that would be helpful to the community?
Trying to figure out if this would benefit everyone at large, making it worthwhile to submit a patch, or if we're the only ones that need this, so we such just live with editing the core file.
-
Re: Expanding the Specialized File Type List

25 March 2009 at 9:38am
The PDF class mentioned above adds the ability to automatically generate a thumbnail of the PDF (think<a href="$pdfFile.URL"><img src="$pdfFile.Thumbnail.src" />Download $pdfFile.Title</a>).
-
Re: Expanding the Specialized File Type List

28 February 2010 at 11:01pm
Hi Ben,
Just search for "icons for .pdf's" and found this. I'm really quite interested in you code. Would you be able to post it to the forum ?
Cheers
Robin
-
Re: Expanding the Specialized File Type List

25 March 2010 at 2:14pm
Hi Ben,
Just discovered that the project that I need the make icons for .pdf files is going ahead. Just wondering if you could post you PDF class or maybe we could talk about you doing some work on my project as freelance project.
Cheers
Robin
-
Re: Expanding the Specialized File Type List

25 March 2010 at 2:29pm
Ben, definitely worth a patch - I'd like to see this in Core.
-
Re: Expanding the Specialized File Type List

13 December 2011 at 4:54am
What happened to this. I need to find out about generating PDF thumbnails, but cannot see the hack for the folder.php can anyone enlighten me with the details of how to do this.
| 1359 Views | ||
|
Page:
1
|
Go to Top |



