Last active
January 19, 2016 20:50
-
-
Save rugor/df592f116aaac42295dc to your computer and use it in GitHub Desktop.
Add data attributes to wordpress gallery image srcs #rugor #st
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
function wpdocs_filter_gallery_img_atts( $atts, $attachment ) { | |
if ( $full_size = wp_get_attachment_image_src( $attachment->ID, 'full' ) ) { | |
if ( ! empty( $full_size[0] ) ) { | |
$atts['data-full-size'] = $full_size[0]; | |
} | |
} | |
$atts['data-width'] = $full_size[1]; | |
$atts['data-height'] = $full_size[2]; | |
$atts['data-caption'] = $attachment->post_excerpt; | |
// $atts['data-description'] = $attachment->post_content; | |
return $atts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment