Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. add_filter('wp_get_attachment_image_attributes', 'interchange_the_images', 10, 2);
  3.  
  4. function interchange_the_images ( $attr, $attachment )
  5. {
  6. /* Use ID to get the attachment object */
  7. $lg_hero_array = wp_get_attachment_image_src( $attachment->ID, 'large', true ); //Large Hero
  8. $md_hero_array = wp_get_attachment_image_src( $attachment->ID, 'medium', true ); // Medium Hero
  9. $sm_hero_array = wp_get_attachment_image_src( $attachment->ID, 'thumbnail', true ); // Mobile Hero
  10.  
  11. /* Grab the url from the attachment object */
  12. $hero_lg = $lg_hero_array[0]; //Large Hero
  13. $hero_md = $md_hero_array[0]; // Medium Hero
  14. $hero_sm = $sm_hero_array[0]; // Mobile Hero
  15.  
  16. $attr['interchange'] = '[' . $hero_lg . ', (default)],[' . $hero_sm . ', (small)],[' . $hero_md . ', (medium)],[' . $hero_lg . ', (large)]';
  17. return $attr;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement