So when I create a new post and I upload an image onto the my server.
Normally depending on the size of the image you can select small, medium, large image to place inside the post. On other sites that I have with WordPress, if I select medium image and insert, WordPress will place <a href="...uploads/full-size-img.jpg"><img src="medium.jpg"></a>
. Then if I was to insert a full size image, WordPress would know that I don’t need the <a href="...upload/full-size-img.jpg"></a>
around the full size image.
The problem I have at the moment is that now it always thinks I need an <a href="upload/full-size-img.jpg"></a>
around all my images even if it is a full sized image already. When I select the none option in the inserting image popup window, the next time I try to insert a medium sized image, it doesn’t detect that I would need the <a href="...uploads/full-size-img.jpg"><img src="medium.jpg"></a>
.
I could keep changing the link option in the image inserting window, from “none” when it is full size image to “file URL” to when it’s a medium sized image. But with my site I have 26 different writers so I would have to explain to all of them what to do.
The following code will empty the
Link URL
field whenFull Size
button is clicked. And fill the same field with theFile URL
value when other buttons are clicked.Tested with WordPress 3.4.2. Drop the code in your theme’s
functions.php
file or create a simple plugin for it.