I’m looking to pull all of the metadata (e.g. alt, width, height) from the theme logo which is uploaded through Appearance -> Customization into my theme template file. This is what I currently have but it’s not working:

$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
    $image = wp_get_attachment_image_src($custom_logo_id, 'full');
    $meta = wp_get_attachment_metadata($custom_logo_id);
    echo '<img src="' . $image[0] . '" alt="' . $meta['alt'] . ' width="' . $meta['width'] . '" height="' . $meta['height'] . '">';
} else {
    echo bloginfo('name');
}

Read more here: Theme logo metadata into template file


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: