metaslider_resized_image_url

Description

Usethis filter to modify the slide image URL used by MetaSlider. For example, it could be used to change the full image URL to a relative image URL.

Parameters

$cropped_url

(string) (required) The URL to the cropped/resized image (e.g. http://[…]/image-150×150.jpg)

$orig_url

(string) (required) The URL to the full size image (e.g.  http://[…]/image.jpg)

Examples

Protocol Relative URLs

The example below will remove the “http:” portion of the image URL, making it into a “protocol relative URL”. This will allow the image to be loaded over the same protocol as the page itself (ideal for https pages).

function metaslider_protocol_relative_urls($cropped_url, $orig_url) {
    return str_replace('http://', '//', $cropped_url);
}
add_filter('metaslider_resized_image_url', 'metaslider_protocol_relative_urls', 10, 2);

Disable Cropping

The example below effectively disables cropping by returning the original, full size image URL for each slide.

function metaslider_disable_crop($cropped_url, $orig_url) {
    return $orig_url;
}
add_filter('metaslider_resized_image_url', 'metaslider_disable_crop', 10, 2);

Posted in: Developer API