Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Created July 15, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hereswhatidid/078b8641acf84a37c0df to your computer and use it in GitHub Desktop.
Save hereswhatidid/078b8641acf84a37c0df to your computer and use it in GitHub Desktop.
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