All my inserted images gets a link to the full image even if it is already full size image

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. The following code will empty the Link URL field when Full Size button is clicked. And fill the same field with the File 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.

    add_action( 'admin_head-media-upload-popup', 'wpse_41539_add_remove_image_url' );
    
    function wpse_41539_add_remove_image_url() 
    {
        // Don't run if viewing "From URL" tab
        if( 'type_url' != $_GET['tab'] ) 
        {
            ?>
            <script type="text/javascript">
            jQuery(document).ready( function($) 
            {
                /*
                 * If Full Image size selected, empty the URL field
                 */
                $(document).on('change','input[type="radio"][value="full"]',function(){
                    $(this).parent().parent().parent().parent()
                    .find('tr.url td.field button.urlnone').click();
                });
    
                /*
                 * If other image sizes selected, fill the URL field with the File URL
                 * Change "button.urlfile" to "button.urlpost" to use the Attachment Post URL
                 */
                $(document).on('change','input[type="radio"][value!="full"]',function(){
                    $(this).parent().parent().parent().parent()
                    .find('tr.url td.field button.urlfile').click();
                });
            });
            </script>
            <?php
        }
    }