Forum Replies Created

Viewing 1 replies (of 1 total)
  • Incase anyone still has this problem, I followed this article to get the attachment ID then did this:

    function getCurrHeaderSrcSet() {
        $data = get_theme_mod('header_image_data');
        $data = get_object_vars($data);
    
        $attachment_id = is_array($data) && isset($data['attachment_id']) ? $data['attachment_id'] : false;
        $img_srcset = wp_get_attachment_image_srcset( $attachment_id, 'medium' );
    
        return $img_srcset;
    };
    add_filter( 'currHeaderSrcSet', 'getCurrHeaderSrcSet' );

    Then in the template you can do srcset="<?php echo apply_filters( 'currHeaderSrcSet', '' ); ?>"

    • This reply was modified 9 years, 7 months ago by cwiglar.
Viewing 1 replies (of 1 total)