0

I would like to change the URLs in my Slider, which was built with the default Wordpress Slider admin, to relative from absolute.

I note that when I select a image from the Media Library the URLs are absolute, so this may be where my problem lies. I would like these to be relative.

I have had a look at: https://www.webhostinghero.com/how-to-insert-relative-image-urls-in-wordpress/

and in particular this code:

function switch_to_relative_url($html, $id, $caption, $title, $align, $url, $size, $alt)
{
    $imageurl = wp_get_attachment_image_src($id, $size);
    $relativeurl = wp_make_link_relative($imageurl[0]);
    $html = str_replace($imageurl[0],$relativeurl,$html);

    return $html;
}
add_filter('image_send_to_editor','switch_to_relative_url',10,8);

...however it has no effect on the URLs in my slider.

Is there a way to change all media library URLs to relative? I am on Wordpress 4.8.3.

3
  • It may not be wise to change all media to relative URLs. See this question & answer for insight.
    – Pat J
    Commented Nov 15, 2017 at 16:41
  • Also, I'm not clear on what you mean by default WordPress Slider admin, since, to my knowledge, there is no "default WordPress Slider".
    – Pat J
    Commented Nov 15, 2017 at 16:42
  • You have a plugin or included functionality in your theme that has created that slider.
    – jdm2112
    Commented Nov 15, 2017 at 16:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.