• Resolved nuahssiaram

    (@nuahssiaram)


    Thank you for developing this great plug-in.

    I was wondering if you could help – I have been sitting with this issue for a couple of hours now.

    Is there a way of accessing image attributes and dynamically adding width and height?

    if( class_exists(‘Dynamic_Featured_Image’) ) {
    global $dynamic_featured_image;
    $featured_images = $dynamic_featured_image->get_featured_images( );
    //print_r($featured_images);

    //You can now loop through the image to display them as required
    foreach($featured_images as $featured_image) {

    $image_attributes = wp_get_attachment_image_src( $featured_image [‘full’] );

    $width = $image_attributes[1];
    $height = $image_attributes[2];
    echo “<img src='”.$featured_image[‘full’].”‘”;
    echo “width='”.$width.”‘”;
    echo “height='”.$height.”‘”;
    echo ‘/>’;
    }
    }

    https://www.ads-software.com/plugins/dynamic-featured-image/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ankit Pokhrel

    (@ankitpokhrel)

    Hello @nuahssiaram,

    You are using wrong syntax here:
    $image_attributes = wp_get_attachment_image_src( $featured_image ['full'] );

    wp_get_attachment_image_src takes attachment id instead of image src. try this to get image size:
    $image_attributes = wp_get_attachment_image_src( $featured_image ['attachment_id'] );

    The support for the plugin is now moved to this forum. Please login and post in new forum further queries.

    Thank you for your consideration.

    Regards,
    Ankit

    Thread Starter nuahssiaram

    (@nuahssiaram)

    That was my original thinking but I couldn’t get the right size.

    So, now it works! Just add in ‘full’ to get the right size.

    $image_attributes = wp_get_attachment_image_src( $featured_image [‘attachment_id’], ‘full’ );

    Thanks for that!
    I’ve featured the usefulness of your plugin on my blog.

    Plugin Author Ankit Pokhrel

    (@ankitpokhrel)

    Glad to know that your issue is solved. Feel free to share your blog link ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamically insert width and height’ is closed to new replies.