WordPress.org

Ready to get started?Download WordPress

Forums

Nav Menu Images
SVG raw data output (1 post)

  1. stereoactivo
    Member
    Posted 4 months ago #

    Hi! I tried to modify your plugin to create a condition when if the attached image is a SVG, the raw content of the SVG is output, but I gave up.

    There is what I tried:

    function menu_item_content ($content, $item_id) {
    		if (get_post_mime_type ($item_id) == 'image/svg+xml') {
    			$content = //raw data of attachment
    	}
    		else {
    			if (has_post_thumbnail ($item_id)) {
    				$content = apply_filters ('nmi_menu_item_content', get_the_post_thumbnail ($item_id, 'full', array ('alt'   => $content,
    				                                                                                                    'title' => $content
    				)), $item_id, $content);
    			}
    		}
    		if (has_post_thumbnail ($item_id)) {
    			$content = apply_filters ('nmi_menu_item_content', get_the_post_thumbnail ($item_id, 'full', array ('alt'   => $content,
    			                                                                                                    'title' => $content
    			)), $item_id, $content);
    		}
    		return $content;
    	}

    But the function get_post_mime_type ($item_id) always returns an empty string. Is a rare behaviour because if I use the function with an integer: get_post_mime_type (249), the string is not empty.

    Maybe you can help me to know what's wrong and I can finish the modification.

    https://wordpress.org/plugins/nav-menu-images/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.