{ category: "Front-end" }
function filter_wp_calculate_image_srcset($sources, $size_array, $image_src, $image_meta, $attachment_id) {
foreach ($sources as $source) {
$previos_url = $source['url'];
if (preg_match('/^http(s)?:\/\/[^\/\s]+(.*)$/', $previos_url, $match)) {
$url = $match[2];
$sources[$source['value']]['url'] = $url;
}
}
return $sources;
}
add_filter('wp_calculate_image_srcset', 'filter_wp_calculate_image_srcset', 10, 5);