Title: Dynamically insert width and height
Last modified: August 22, 2016

---

# Dynamically insert width and height

 *  Resolved [nuahssiaram](https://wordpress.org/support/users/nuahssiaram/)
 * (@nuahssiaram)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/dynamically-insert-width-and-height/)
 * 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://wordpress.org/plugins/dynamic-featured-image/](https://wordpress.org/plugins/dynamic-featured-image/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Ankit Pokhrel](https://wordpress.org/support/users/ankitpokhrel/)
 * (@ankitpokhrel)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/dynamically-insert-width-and-height/#post-5790703)
 * Hello [@nuahssiaram](https://wordpress.org/support/users/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](http://ankitpokhrel.com.np/blog/forums/forum/dynamic-featured-image-free-version/).
   Please login and post in new forum further queries.
 * Thank you for your consideration.
 * Regards,
    Ankit
 *  Thread Starter [nuahssiaram](https://wordpress.org/support/users/nuahssiaram/)
 * (@nuahssiaram)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/dynamically-insert-width-and-height/#post-5790810)
 * 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](https://wordpress.org/support/users/ankitpokhrel/)
 * (@ankitpokhrel)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/dynamically-insert-width-and-height/#post-5790842)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/dynamic-featured-image_444643.svg)
 * [Dynamic Featured Image](https://wordpress.org/plugins/dynamic-featured-image/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/dynamic-featured-image/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/dynamic-featured-image/)
 * [Active Topics](https://wordpress.org/support/plugin/dynamic-featured-image/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dynamic-featured-image/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dynamic-featured-image/reviews/)

## Tags

 * [height](https://wordpress.org/support/topic-tag/height/)
 * [width](https://wordpress.org/support/topic-tag/width/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ankit Pokhrel](https://wordpress.org/support/users/ankitpokhrel/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/dynamically-insert-width-and-height/#post-5790842)
 * Status: resolved