Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter('wp_get_attachment_image_attributes', 'interchange_the_images', 10, 2);
- function interchange_the_images ( $attr, $attachment )
- {
- /* Use ID to get the attachment object */
- $lg_hero_array = wp_get_attachment_image_src( $attachment->ID, 'large', true ); //Large Hero
- $md_hero_array = wp_get_attachment_image_src( $attachment->ID, 'medium', true ); // Medium Hero
- $sm_hero_array = wp_get_attachment_image_src( $attachment->ID, 'thumbnail', true ); // Mobile Hero
- /* Grab the url from the attachment object */
- $hero_lg = $lg_hero_array[0]; //Large Hero
- $hero_md = $md_hero_array[0]; // Medium Hero
- $hero_sm = $sm_hero_array[0]; // Mobile Hero
- $attr['interchange'] = '[' . $hero_lg . ', (default)],[' . $hero_sm . ', (small)],[' . $hero_md . ', (medium)],[' . $hero_lg . ', (large)]';
- return $attr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement