0

I have near 800 post/page in my site and 3800 images. I actually set Large Size to 600px width but in my new theme i want my image width be 880px.

So i would like to switch all my image to Full-Size and don't do that one by one. :D

Have you any idea to do that ?

I try to delete Large, etc, but always have 404 with :

   www.truc.fr/wp-content/uploads/2016/03/survival-600x351.jpg

in my post instead of

   www.truc.fr/wp-content/uploads/2016/03/survival.jpg

Thank you for the delete and sorry for the bad English i'm french.

0

You can use the_content filter to filter all post content and replace img sources.

add_filter( 'the_content', 'show_full_sized_images' );
/**
 * Replaces all -600x999 images with full image url
 * @param string $content
 * @return string
 */
function show_full_sized_images( $content ) {

    $pattern = '~(http[^\'"]*)(-600x[0-9]{2,4})(\.jpe?g|png|gif)~i';

    $m = preg_match_all( $pattern, $content, $matches );

    echo '<pre>' . esc_html( print_r( $matches, 1 ) ) . '</pre>';

    return preg_replace( $pattern, '$1$3', $content );
}

You'll also need to add following css because width may be limited by width attribute in img tag:

img {
    width: auto;
    height: auto;
}
  • Thank you, but it make me 2 errors : Warning: preg_match_all(): Compilation failed: missing terminating ] for character class at offset 52 in /home/nopanicv4/wp-content/themes/NoPanic/functions.php on line 55 Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 52 in /home/nopanicv4/wp-content/themes/NoPanic/functions.php on line 59 – Fluti May 4 '16 at 10:03
  • And it's not really my question, i would like to switch all Large image by Full Size image in the Wysiwyg of all my post/page. – Fluti May 4 '16 at 10:28
  • @Fluti Compilation error fixed. – TheDeadMedic May 4 '16 at 11:22

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.