Topic on Skin talk:Minerva Neue

How to add an image to a new menu item?

5
24pm (talkcontribs)

I would like to add Recent Changes menu item with an image. Everything works except image. It does not appear. That's what I did:

1) Put recentchanges.svg into /skins/MinervaNeue/resources/skins.minerva.mainMenu.icons/

2) In skin.json in section "skins.minerva.mainMenu.icons"add line:

       "recentchanges": "resources/skins.minerva.mainMenu.icons/recentchanges.svg",

3) In SkinMinerva.php (includes/skins/) in function getDiscoveryTools() add lines:

// new menu item: Special:Recentchanges

$menu->insert( 'recentchanges' )

   ->addComponent(

       $this->msg( 'recentchanges' )->escaped(),

       SpecialPage::getTitleFor( 'recentchanges' )->

           getLocalUrl( array( 'returnto' => $returnToTitle ) ),

       MobileUI::iconClass( 'recentchanges', 'before' ),

       array( 'data-event-name' => 'recentchanges' )

   ); 

I've tried PNG image. It does not appear either.But if I use image from distribution (f.e. home.svg) it works just fine. Is it anywhere else I should mention the new image?

Jdlrobson (talkcontribs)

Rather than edit skin.json you'll probably want to add a CSS rule inside MediaWiki:Mobile or Minerva.css for that icon which applys a background image.

Editing skin.json will be little trickier as it will require adding the icon in question to resources/skins.minerva.mainMenu.icons/ and ensuring the svg is in a certain format.

24pm (talkcontribs)

I've got it work! The instruction I gave is correct. The problem was in object colors inside the image (my fault). SVG was created in Inkscape in native format with layers and a lot of meta information inside SVG code (as it put it in default). Works just fine.

It is no profit to use MediaWiki:Mobile.css or MediaWiki:Minerva.css since you still have to hack the skin code to add an extra menu item.

Thank you Jdlrobson for the answer anyway!

This post was hidden by 24pm (history)
Jdlrobson (talkcontribs)

Great!

Reply to "How to add an image to a new menu item?"