Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Denis V (Artprima)

    (@v-media)

    Hi,

    Check this reply by kyledoesit:

    https://www.ads-software.com/support/topic/different-menu-item-image-sizes?replies=6#post-6883148

    In your case you should try something like this:

    add_action('init', 'remove_then_add_image_sizes');
    
    function remove_then_add_image_sizes() {
    	remove_image_size('fl-menu-tag-icon');
    	add_image_size('fl-menu-tag-icon', $width, $height, $crop);
    }

    Please let me know, if it works for you, as I never tested this code.

    Thread Starter RenaissanceJames

    (@renaissancejames)

    That doesn’t seem to do anything, I’m not sure if its to do with the fact the images are sized upon uploading at that size, could almost do with it using the full image size rather than a generated size.

    I have also tried adding a short code but that doesn’t seem to do much either, and was trying to keep it simple by using the MenuItemThumbnailShortcode.php and removing the “align left” class, but this just displays my short code, I might be missing a step.

    Where do you save the copied Shortcode.php file?
    Chhers

    Plugin Author Denis V (Artprima)

    (@v-media)

    Wait, I thought you meant tag icon size, which is 16×16, but menu item thumbnail is not 16×16, it’s 100×100 by default, and the solution for changing menu item thumbnail is described at the link I posted before (there are two solutions actually, and they should both work). The solution by kyledoesit is simpler, my solution is more Foodlist-way (and I tested it personally). You need to do any of them accurately step by step. If you lack php skills for doing that you can hire me to assist you. Here is the contact form: https://artprima.eu/contact-us

    Thread Starter RenaissanceJames

    (@renaissancejames)

    Hi,

    Yes I want to change the tag icon size. But I’d also like to remove the “alignleft” class added to thumbnail images.

    So I thought I’d use your instructions directly to edit this.

    So I followed the instructions of adding a new shortcode as per the post mentioned.

    This is “MenuItemThumbnailShortcode.php” in my theme folder, inside another folder foodlist_ext

    <?php
    
    namespace foodlist_ext;
    
    use Artprima\Text\Shortcode;
    use Artprima\Text\ShortcodeManager;
    use Foodlist\Project\WordPress\Plugin\Foodlist\Manager;
    
    class MenuItemThumbnailShortcode extends Shortcode {
    
        public function getTag()
        {
            return 'menu_item_thumbnail_casa';
        }
    
        public function apply($attrs, $content = null)
        {
            $cur = Manager::getInstance()->get('curitem');
            $postData = $cur->getPostData();
            $id = $postData['id'];
    
            $result = '';
            if (has_post_thumbnail($id)) {
                $result = get_the_post_thumbnail($id, 'fl-menu-item-thumb', array('class' => 'fl-menu-item-thumb'));
            }
    
            return $result;
        }
    
    }

    Adding to my functions.php

    function my_register_thumbnail_shortcode(\Artprima\Text\ShortcodeManager $sm) {
    		$sm->registerShortcode(new \foodlist_ext\MenuItemThumbnailShortcode());
    	}
    	add_action('foodlist_register_menuitem_shortcode', 'my_register_thumbnail_shortcode');

    Now it crashes the menu out, without including the new shortcode on the page.

    Should the PHP be in a different folder? I’m fairly proficient in PHP, but the fact that following your instructions it crashes out seems strange.

    Cheers

    Plugin Author Denis V (Artprima)

    (@v-media)

    Look, why don’t you just use menu_item_thumbnail_url?

    <img src=”[menu_item_thumbnail_url]” alt=”” class=”whatever” />

    P.S. By the way, I tested your code and it works for me. You probably forgot to include (or require) the shortcode file (require_once 'foodlist_ext/MenuItemThumbnailShortcode.php';).

    Plugin Author Denis V (Artprima)

    (@v-media)

    Also, instead of doing anything with php, you can just redefine css:

    .fl-menu-item-thumb.alignleft {
    /* any rules that you need */
    }
    Thread Starter RenaissanceJames

    (@renaissancejames)

    Hey,

    Thanks, I was requiring the wrong file somehow, sleep deprived.

    Cheers for the help, all working and resolved.

    Awesome support.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Icon size’ is closed to new replies.