Created
July 15, 2015 18:05
-
-
Save hereswhatidid/078b8641acf84a37c0df to your computer and use it in GitHub Desktop.
Apply Foundation Interchange parameters to attachment images via filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment