"Add new mime type" in Mime Types module replaces existing mime type + idea for fix

georgesz

Joined: 2006-11-02
Posts: 5
Posted: Sat, 2007-02-17 02:32

I wanted to add .thm extension as a new extension to the "image/jpeg" mime type. File with the .thm extension are jpeg thumbnail of movies in the Canon powershot cameras with all the EXIF information for the movie. Unfortunately, I clicked the "Add new mime type" button instead of editing the exiting mime type. I enter "image/jpeg" in mime type and thm in extension and clicked save. It ended up removing the existing extensions for the "image/jpeg" mime type.

Looking at the code (2.2 RC1), I now understand where the problem come from and have some ideas on how to fix the problem in the mime types module. I could patch the code so that it notify the user if he would be loosing some extensions, or simply merge the existing extension once the user click Save or Apply. In the first case, I would need to add a function to modules\core\classes\GalleryCoreApi.class, modules\core\classes\helpers\GalleryMimeTypeHelper_simple.class and/or modules\core\classes\helpers\GalleryMimeTypeHelper_advanced.class that returns whether a given mime type already has extensions. In the second case, I would need to add a function to return the list of extension for given mime type.

Any recommendation on which way I should go regarding the files in the core module?

Thanks.

Georges


Gallery version = 2.2-rc-1 core 1.1.26
PHP version = 5.2.0 apache2handler
Webserver = Apache/2.2.3 (Win32) PHP/5.2.0
Database = mysql 5.0.27-community-nt, lock.system=database
Toolkits = Exif, ImageMagick, ArchiveUpload, Thumbnail, Gd, Ffmpeg, NetPBM, LinkItemToolkit
Acceleration = none, none
Operating system = Windows NT JODA 5.1 build 2600
Default theme = hybrid
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Rows in GalleryAccessMap table = 91
Rows in GalleryAccessSubscriberMap table = 1748
Rows in GalleryUser table = 4
Rows in GalleryItem table = 1740
Rows in GalleryAlbumItem table = 34
Rows in GalleryCacheMap table = 0

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2007-02-17 03:02

i think it should simply show an error message and not allow that action.
e.g. "'image/jpeg' is already associated with .... Please edit the existing MIME type image/jpeg"

and you can use MimeHelper::getMimeTypeMap(); or just GalleryCoreApi::getMapEntry() to look for such collisions.

thanks for taking a stab at it!

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage