Permalink
Browse files

remove cropped images from the list used in srcset

  • Loading branch information...
Joe McGill
Joe McGill committed Dec 31, 2014
1 parent df3ae78 commit 1718c993b1431f0c9911e12c25b34f3c927af08b
Showing with 16 additions and 1 deletion.
  1. +16 −1 wp-tevko-responsive-images.php
@@ -44,6 +44,21 @@ function tevkori_get_src_sizes( $id, $size ) {
// default sizes
$default_sizes = $image['sizes'];
// grab an array of all defined custom image sizes
global $_wp_additional_image_sizes;
$custom_sizes = $_wp_additional_image_sizes;
// find all the sizes which are hard-cropped
$hard_crops = array();
foreach ( $custom_sizes as $custom_size => $params ) {
if ( $params['crop'] ) {
$hard_crops[$custom_size] = $params;
}
}
// remove hard crops
$default_sizes = array_diff_key( $default_sizes, $hard_crops );
// choose sizes based on the users needs.
$width = ( !empty($image['width']) && $size != 'full' ) ? $image['sizes'][$size]['width'] : $image['width'];
@@ -96,4 +111,4 @@ function tevkori_extend_image_tag( $html, $id, $caption, $title, $align, $url, $
*/
function tevkori_editor_image_size( $max_image_size ){
return array( 99999, 99999 );
}
}

0 comments on commit 1718c99

Please sign in to comment.