SVG raw data output
-
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.
- The topic ‘SVG raw data output’ is closed to new replies.