I have changed my WordPress blog theme but now in older posts images are not working. I have used images names with space :/ and it is not working now in this theme. I can see the name like something%20icon.png. Can I fix it somehow? Not manually all image.

Update: I have find out that problem is that old images that are not working are in root/images (new one are in wp-content\upload...). If I tried url of some image, website.com/images/image.jpg it will open main website not an image. There are images in directory.

  • 1
    What do you mean with not working? Do you get a 404 for these images? That shouldn't be related to the theme at all. – fuxia Oct 27 '16 at 11:23
  • I see there is a plugin that converts spaces to dashes for files in media library: Clean Image Filenames – Arslan Farooq Oct 27 '16 at 12:22

You can test flowing code

$img_space = 'something icon.png';
$img_without_space = preg_replace('/\s+/', '', $im);
echo $image;
  • Please edit your answer, and add an explanation: why could that solve the problem? The original image locations stay the same. – fuxia Oct 27 '16 at 11:24
  • ah sry, I have found that problem is not in that space... Some of images are in direcotry images which is in root and new images are in wp-content\uploads\... But when I tried to open some image with www.website.com\images\example.png, it still open main page, www.website.com... not image. But images are on the server... where should be problem, just some permission...? – vb381 Oct 27 '16 at 11:57

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