Topic on Project:Support desk

Gallery tag and not existing images. Perhaps, a custom placeholder?

8
195.234.75.155 (talkcontribs)

Hi.

Is it possible to specify how not existing images should be displayed for the <gallery> tag? Currently the tag just renders file names if the respective images are not found in my MediaWiki instance. I would like to change that placeholder to a custom one, showing something like a default image with an upload prompt (for example, a JPEG/PNG with "no image found" depicted). Is it possible or should I use another extension?

Thanks!

195.234.75.155 (talkcontribs)

Up.

195.234.75.155 (talkcontribs)

Up the last time.

Florianschmidtwelzow (talkcontribs)

I don't know an option or something else to do this. But there is a hook, that can handle this: BeforeParserFetchFileAndTitle. It should be easy to check, if the passed Title object exists, and if not, replace it with another one (e.g. a Title object of an "not-found" image). I haven't found (and don't know any) an extension, that handles this already, so maybe you want to create one? :)

195.234.75.155 (talkcontribs)

Thank you! :) Although I'm not a PHP developer, it your suggestion sounds really good to me. I'll check it as soon as I can. Thanks again!

Florianschmidtwelzow (talkcontribs)

It's a little bit more complicated as i said, because this hooks doesn't allow to change the title (maybe a point to file a feature request bug). So to replace images with a placeholder, you need to implement your own galleryclass. I've taken the liberty and do this in an extension. You can fnd it here:

https://github.com/Florianschmidtwelzow/mediawiki-extensions-ImagePlaceholder

It's completly untested and may or may not work like expected.

Problem: You need to adjust a file in your MediaWiki installation because there is a little fault. Open includes/gallery/ImageGalleryBase.php and find GalleryGetModes. Replace self::$modeMapping with array( &self::$modeMapping ). I will upload a patch for this, so this don't need to be needed in future versions of MediaWiki.

MarkAHershberger (talkcontribs)

I would look for a way to do this with CSS. Have you tried that?

195.234.75.155 (talkcontribs)

Thanks for the answer! I'm not sure if CSS fits the requirement well, because I would like to have a way to specify rich markup there for more flexibility (doesn't really matter: wiki markup or HTML). I've just checked what selector I could apply with your suggestion and this is what I have for not existing image: <a href="/w/index.php?title=Special:Upload&wpDestFile=FooBar.jpg" class="new" title="File:FooBar.jpg">100x100px</a> -- I can't handle the size here, unfortunately, and the wiki doesn't specify the size of the placeholder too.

Reply to "Gallery tag and not existing images. Perhaps, a custom placeholder?"