Title: adding srcset
Last modified: March 29, 2017

---

# adding srcset

 *  Resolved [ugy](https://wordpress.org/support/users/ugy/)
 * (@ugy)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/adding-srcset/)
 * Hi Navneil,
    This is a very useful plugin. I’ve added some extra code to add 
   srcset capabilities in my local version & wondered if you’d thought about doing
   the same, or if I could contribute the small changes I’ve made to your project.
   The implementation I have isn’t perfect as it requires the thumbnail size to 
   be hard-coded in:
 *     ```
       foreach($images as $image):
       			$title = $image->post_title;
       			$content = $image->post_content;
       			$meta_data = wp_get_attachment_metadata($image->ID);
       			$large_url = wp_get_attachment_url($image->ID, 'large');
       			$large_srcset = wp_get_attachment_image_srcset( $image->ID,'large', $meta_data);
       			$thumbnail_url = wp_get_attachment_thumb_url($image->ID);
       			$thumb_srcset = wp_get_attachment_image_srcset( $image->ID,array(150,150), $meta_data);
       			$url = get_post_meta($image->ID, $field . '_url', true);
       			$target = get_post_meta($image->ID, $field . '_target', true);
       			$array[] = array(
       				'id' => $image->ID,
       				'title' => $title,
       				'caption' => $content,
       				'large_image_url' => $large_url,
       				'large_srcset' => $large_srcset,
       				'thumbnail_image_url' => $thumbnail_url,
       				'thumb_srcset' => $thumb_srcset,
       				'url' => $url,
       				'target' => $target
       			);
       		endforeach;
       ```
   
 * Best wishes,
    Guy

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

 *  Plugin Author [Navneil Naicker](https://wordpress.org/support/users/navzme/)
 * (@navzme)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/adding-srcset/#post-8973085)
 * [@ugy](https://wordpress.org/support/users/ugy/)
    Thank you very much for your
   contribution. I will surely include your code in the next release.
 * Cheers!
 *  Thread Starter [ugy](https://wordpress.org/support/users/ugy/)
 * (@ugy)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/adding-srcset/#post-8991846)
 * That’s great!
    As I mentioned, it’s a far from perfect solution for including
   srcsets.

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

 The topic ‘adding srcset’ is closed to new replies.

 * ![](https://ps.w.org/navz-photo-gallery/assets/icon-128x128.png?rev=2607741)
 * [ACF Photo Gallery Field](https://wordpress.org/plugins/navz-photo-gallery/)
 * [Support Threads](https://wordpress.org/support/plugin/navz-photo-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/navz-photo-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/navz-photo-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/navz-photo-gallery/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [ugy](https://wordpress.org/support/users/ugy/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/adding-srcset/#post-8991846)
 * Status: resolved