New fallbackImage not showing up


I’ve added a new image to my repository, meant to show up for .doc files that do not get resolved, but I still get the GENERIC_FALLBACK_IMAGE instead, so I suppose there’s something wrong… hope someone can cast some light on this.

These are the steps I’ve followed so far:

  1. created a new PNG image, called fallback-doc.png, and saved it in /application/views/scripts/images;
  2. in FileMarkup.php added to the array $_fallbackImages the following line:

‘doc’ => ‘fallback-doc.png’,

  1. in FileMarkup.php, added to the array $_fileExtensionCallbacks the following lines:

// application/msword
‘doc’ => ‘doc’,

  1. in FileMarkup.php, added to the array $_callbacks the following line:

‘application/msword’ => ‘doc’,

The callbacks don’t relate to the fallback images… the keys for fallback images are actually mime types directly. The default ones you see are for matching all audio/, video/, and image/ types respectively, but you can put a full type there also.

You can also modify the fallback images without editing the core: you can just call add_file_fallback_image in a plugin or your theme’s custom.php.

John, thanks for your reply.
I am not sure so what I am doing wrong; only thing I know is that the new fallback_image for msword file doesn’t show up, and instead I see the generic one. Would you have any idea?

(p.s.: I was aware of the add_file_fallback_image, but I decided to intervene on the core because I wanted to change also the default fallback images)

The other two changes you made, to the “callbacks” arrays, are totally irrelevant for the purposes of the fallback images.

The fallback images array change isn’t working because the key there needs to be a MIME type, like application/msword (or whatever your Word documents are being detected as, since there are a few possibilities there).

Also, note that you can override the default fallback images easily in a theme by simply putting images at matching paths within your theme. Of course that will only work on the public side. add_file_fallback_image, despite its name, will also let you change a fallback image that’s already set.

And again, John, thanks for your input.

By using your suggestion

I’ve managed to create a plugin that adds the new Media Types (on demand), and also can replace the original fallback images (thus not touching the core)…

…with one exception, sadly: I could not replace the default fallback image, whose name is defined in GENERIC_FALLBACK_IMAGE inside the FileMarkup.php, and is returned when every mime types association fail. Any idea about it, or there’s nothing to be done?

Any idea, anyone?

Solved the problem: a tweak of the application/views/helpers/FileMarkup.php core file is needed; see for details, and then the plugin if you wanted to add/change fallback images.