0

I'm trying to create a function that always inserts the full size image that was uploaded. My first thought was something like this:

function image_tag($id, $alt, $title, $align, $size) {
    $size = 'full';
    return $html;
}
add_filter('get_image_tag', 'image_tag', 10, 5);

Unfortunately that doesn't display anything on upload.

P.S. I do not want to have to manually set this is the Insert Media > Upload Files > Select Files > Attachment Display Settings > Size.

  • Can i just clarify what you mean, so when someone uploads an image into the editor (no matter the size settings) when the post is viewed that image on the front end will always be full size? – Jim-miraidev Nov 9 '17 at 13:48
  • @Jim-miraidev that's correct – Troy Templeman Nov 9 '17 at 14:25
  • I have a JavaScript solution,which i can post if you want? – Jim-miraidev Nov 10 '17 at 16:54
  • did you find a solution? – Jim-miraidev Nov 13 '17 at 13:58
0

Not a PHP solution, but below is a jQuery option.

    var images = $('.entry-content img');

    images.each(function() {
        var src = $(this).attr('src'),
            // removes the  img size off the src e.g -300x300.
            newsrc = src.replace(/-\d+[Xx]\d+\./,'.');         
        $(this).attr('src',newsrc);
    });

You would need to remove some of the classes e.g size-thumbnail

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.