diff --git a/wp-thumbor.php b/wp-thumbor.php index e0a02ac..8900077 100644 --- a/wp-thumbor.php +++ b/wp-thumbor.php @@ -298,7 +298,15 @@ function wp_thumbor_output_buffer_callback($buffer) { foreach ( $srcsetItems as $item ) { $parts = preg_split('/\s+/', trim($item)); if ( ! empty($parts[0]) && preg_match('/^https?:\/\//', $parts[0]) ) { - $newURL = wp_thumbor_transform_url($parts[0]); + $width = null; + $height = null; + if ( isset($parts[1]) && preg_match('/^(\d+)w$/i', $parts[1], $m) ) { + $width = intval($m[1]); + } elseif ( isset($parts[1]) && preg_match('/^(\d+)h$/i', $parts[1], $m) ) { + $height = intval($m[1]); + } + $newURL = wp_thumbor_transform_url($parts[0], $width, $height); + $newSrcset[] = isset($parts[1]) ? $newURL . ' ' . $parts[1] : $newURL; } else { $newSrcset[] = $item;