Page MenuHomePhabricator

*.ico files could be uploaded (after patching) but are not rendered inline and not thumbnailed (solution needed)
Closed, DeclinedPublic

Description

I wanted to create a small image gallery aka 'favicons'.

I found two problems, the first one while uploading

debug.log:
WebRequest::getFileName() 'myfavicon.ico' normalized to 'myfavicon.ico'
Block::load: '84.191.72.110', '1', 1
MimeMagic::MimeMagic: loading mime types from includes/mime.types
MimeMagic::MimeMagic: loading mime info from includes/mime.info
MimeMagic::detectMimeType: no magic mime detector found!
MimeMagic::detectMimeType: image mime type of /tmp/php7eycaa: image/vnd.wap.wbmp
MimeMagic::guessMimeType: final mime type of /tmp/php7eycaa: image/vnd.wap.wbmp
SpecialUpload::verifyExtension: mime type image/vnd.wap.wbmp mismatches file
extension ico, rejecting file

Solution: add in the file /includes/mime.types the line

image/vnd.wap.wbmp ico

Remark: this type was shown in the debug log for several files of different
origin when uploading with Netscape 7.1

and add in /includes/DefaultSettings.php the file extension to the existing array

$wgFileExtensions = array(......,  'ico' )

This allows to upload an *.ico file.

However, the image page is not showing the thumbnail, perhaps because the
thumbnail routines cannot render this. But also [[image:myfavicon.ico]] does not
work, i.e. does not render the image (needs to be fixed).

Both problems need review of experts of the /include/Image.php module.


Version: 1.5.x
Severity: normal

Details

Reference
bz4188

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 8:59 PM
bzimport set Reference to bz4188.
bzimport added a subscriber: Unknown Object (MLST).

Most browsers don't support Windows icon files.

First of all, with "image/vnd.wap.wbmp ico" you told mediawiki that windows bmp
files are icon files - that's simply wrong. Get your mime detection to work -
under linux, you can set $wgMimeDetectorCommand= "file -bi", that should do it.
Alternatively, get a version of PHP that has either the fileinfo or the
mime_magic extension compiled in. ico files should be tectected as image/x-icon.

Second, ico-files will not be handeled as images by mediawiki, because many
browsers do not support it, and it can't really be scaled. It could be rendered
server-side using imagemagick in theory, but this is suppressed, because ico
files may contain multiple images (for animations, or different ones for
enabled/disabled, etc), and the software can't know which one to use. You can
hack that locally, if you want, by uncommenting the following line in the
canRender function in Image.php:

#|| $mime === 'image/x-icon' #file may be split into multiple parts

HTH

Note that wbmp isn't Windows Bitmap, it's some other format for use with WAP.

The tip with $wgMimeDetectorCommand= "file -bi" was perfect (I overlooked that
for weeks) !

But now a request for small code cosmetics in CVS HEAD:

Add in DefaultSettings.php in that line 266 a semicolon after -bi"

265 $wgMimeDetectorCommand= NULL; # use internal mime_content_type function,
available since php 4.3.0
266 #$wgMimeDetectorCommand= "file -bi" #use external mime detector (linux)

-->
266 #$wgMimeDetectorCommand= "file -bi"; #use external mime detector (linux)

rowan.collins wrote:

(In reply to comment #4)

Add in DefaultSettings.php in that line 266 a semicolon after -bi"

Done.

Hope, that it's okay when I now wontfix this bugzilla.