media file has //example.com/wp-content/uploads/2015/08/logo.png without http:.

How to change it?

picture URL without http://

I need full http:// address in my posts

  • Is it only 1 image where http is missing? – Luckyfella Aug 21 '17 at 14:12
  • Did you set the URL with http (via settings > general)? – kero Aug 21 '17 at 14:19
  • Hi Sergei. The //url/ is "protocol-relative URL" which makes it possible to access both http and https, depending on your connection. It's a good practice to have it. What's your problem with this? :) – Jack Johansson Aug 21 '17 at 14:36
  • Luckyfella: All images in my wordpress has this type of adress :( No additional setting in my Settings-general – Сергей Самойленко Aug 21 '17 at 14:40
  • I need to change URL because Facebook Crossposting Plugin don't want to get my posts with this type of url (//site.com/image.jpg)... it needs full path – Сергей Самойленко Aug 21 '17 at 14:42

I'm sure some plugin or your theme modifies your attachment url. Try to find wp_get_attachment_url hook in your code or simply create your own with high priority this way:

add_filter('wp_get_attachment_url', function($url) {
 return preg_replace("~^//(.+)$~", "https://$1", $url);
}, 999);

or better:

add_filter('wp_get_attachment_url', function($url) {
  return set_url_scheme($url, 'https');
}, 999);

But I recommend you to find the reason of this attachment url behavior first.


The URLs in your media library are protocol-relative. This means, no matter if you are on a secure protocol or simply HTTP, the link is always following the domain's protocol.

Now, if you are experiencing problem, there is something you can do which is not recommended.

First, make a back-up! There is "No" going back if you make a mistake. Back-up, and back-up everything.

Then, download and install Better search replace plugin. This allows you to replace strings in your database, including serialized data.

Head over to plugin's page, and replace:




Pay attention to slashes, spaces, etc. "Everything" matters here, even a capitalized letter might matter.

  • sorry, but you don't understand me. Please, go to your media-library - there you can see full URL address with http:// - it does not mean - that it Mysql database URL has http://...... it database we have protocol-relative url.. – Сергей Самойленко Aug 21 '17 at 17:40
  • My media library works fine, here is an screenshot. – Jack Johansson Aug 21 '17 at 17:48
  • yes ! i have many wordpress web-sites, and all of them had http:// in media-library URLs... so it's normal ! – Сергей Самойленко Aug 21 '17 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.