Ends up that “alt” is not stored in wp_get_attachment_metadata so I pulled it from the post meta:
$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);
**$alt_text = get_post_meta($custom_logo_id, '_wp_attachment_image_alt', true);**
echo '<img src="' . $image[0] . '" alt="' . $alt_text . '" width="' . $meta['width'] . '" height="' . $meta['height'] . '">';
} else {
echo bloginfo('name');
}
Related Posts:
- Can I create customizer setting that can handle plugin shortcode?
- Theme Customizer not displaying saved values in wp_head (CSS)
- Image cropping isn’t working correctly when using Offload Media
- Customizer Image-Picker Preview Not Working
- Correct was to customise theme using get_theme_mod in scripts
- get_theme_mod not pulling css colors into header using wp_head
- Custom Theme functions.php – Using add_settings_field and input type=”file” to set custom logo
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- How do I remove a pre-existing customizer setting?
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- Theme customizer – settings order
- Custom Image section in Customizer
- Get entered value of customiser field for live preview
- How to remove the Theme Customization Button from the dashboard and themes options page?
- Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
- How to modify an image block in Gutenberg WordPress 5?
- How can I set image sizes and still have responsive images using the srcset attribute?
- Add a dropdown to theme customizer
- Add default Backgrounds
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Theme Customizer : how to create multiple-level panel
- Allow Shortcode in Theme Customizer
- Theme Customizer – Nested Sections?
- Customizer Active Callback not working
- wp_get_attachment_image_attributes not working for me
- Editing the custom background CSS
- Specify image dimensions
- How to get gallery images?
- How to execute conditional script when on new customize.php (Theme Customize) screen
- Is the theme customizer slowing down my site?
- Trigger Customizer saving process with Javascript only
- Adding customizer styles with wp_add_inline_style
- add_image_size is scaling, even though crop is set to true
- Featured Image in 4.4 should be larger on mobile device
- WordPress Customizer Typography: How to load just the unique Google Fonts?
- WordPress Customize — Move “menus” options / field to another section
- How to use the responsive images feature from WP 4.4 in your themes
- Can we add more than one control under a setting in WP theme customizer?
- Widgets panel not displaying in the Theme Customizer
- Confused about image sizing business in WordPress
- Unexpected width and srcset attributes for the_post_thumbnail();
- How do I get gallery thumbnail URL and change the default thumbnail size?
- Is it possible to display the admin bar while in the Theme Customizer?
- How do I get a parent theme modification from a child theme?
- Changing the entire control choices using wp.customize with JavaScript
- Responsive class to all the images in the content
- How to Change CSS Variable value in Theme Customizer Live Preview
- How wordpress handle upload images and how to use them in the code
- How to remove menus section from WordPress theme customizer
- Replace Home with image link inside custom header menu
- Get background color for Live Preview with Theme Customization API?
- Featured Image Size
- Checking if there is an Image inserted – if not don’t display anything
- “Display Site Title and Tagline” checkbox not working?
- How to get custom image size for image uploaded in Customizer
- How to set page template on front using starter content?
- How to set dimensions of the post thumbnails (featured images)
- Default header image does not display
- WordPress Customizer Control with React
- Responsive Images – Generating multiple images from Theme Customizer control upload?
- Modify Javascript Configuration Options for Theme Customizer Colour Picker
- Modify the Additional CSS section (adding a disclaimer)
- How to change the customizer´s sidebar width?
- Cannot get full thumbnail size using the_post_thumbnail
- Theme Customizer – Choose where widget area appears, to let users organise widgets
- wordpress custom theme import and export options for sample data [closed]
- How to hook CSS file according to theme selection in the customizer section
- How i can get widgets areas working in customizer?
- How Can I Create a List of Values to Be Iterated Through via WordPress Customization API?
- Change setting name in Customizer and keep the data
- after_setup_theme, Global Variable and Theme Customizer
- wp_get_attachment_image_src() width and height boolean
- Custom Script Section Only Echoes Text
- How to disable automatic colors in the Twenty Twenty theme?
- WordPress not registering Theme Customization Section
- How to float an image in Gutenberg
- A mystery 300px image size
- How can i add edit shortcut icon in wordpress customizer without using selective refresh?
- Add new panel inside parent panel in WP Customize?
- WP Customize refresh problem
- Input ordering in wordpress theme customizer
- Unable to pass variable on theme cusomizer add_settings()
- Custom Field returning Numerical Value for Image rather than URL
- How to add field customizable by the theme editor to your theme?
- Get a setting value conditionally in the Customizer api
- How to add new args data in $wp_customize->add_setting?
- WP_Customize_Color_Control omitting # symbol
- Hide header texts (Title & Tagline) in custom-header.php
- Why an arugment is missing in wp_get_attachment_image_attributes?
- get_option in header.php not returning value from customizer
- Internal error 500 accessing Theme > Customize
- Reasons why all thumbnail sizes aren’t working
- How to make a local cache of mshots images
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- Using an if statement in the theme customizer page
- How do I Add images uploaded in the post to a default custom field
- attachment.php code or tutorial
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?