• Hello. I want to set all my uploaded images link to media file. Is there a way to do this automatically?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Can you please elaborate this? Confusing…

    Thread Starter zarga

    (@zarga)

    Hello WEN Solutions,

    When you insert a picture in a post, you have some option for that image:

    • You can align the picture
    • You can set the size of the picture
    • And you can set where the picture link to:
    1. To Media File
    2. To Attachment Page
    3. None

    In my case, by default I had the picture link to None, so all the pictures that I have uploaded on my site are linked To None.

    Now I want to set all my uploaded pictures Link To Media File and I don’t want to do this manually for every picture, because there’s a lot.

    Is there a plugin or a solution to do this automatically?

    Moderator bcworkz

    (@bcworkz)

    What you want to do is go through every post and if there are images in the content that come from /wp-includes/upload/ then wrap each img tag with an anchor tag (<a><img/></a>) that links to the full size image file.

    I don’t know of any plugins to do this. It is feasible to do this by script, but you must account for all conditions that could cause errors, like external images, images already with anchor tags, images where there is no larger size, etc. You also need a reliable routine to determine the full size file name from whatever happens to be used in the image tag.

    Test the script carefully and thoroughly on a limited number of posts before turning it loose on the whole DB. You will likely need to extend the execution time for PHP or treat limited blocks of posts at a time once you’re ready to do the entire DB due to how long this is likely to take.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change from "Link to None" to "Link to Media File" for already uploaded images’ is closed to new replies.