Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apply Foundation Interchange parameters to attachment images via filter
<?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
You can’t perform that action at this time.