I want to change my image size. Large is now 600px wide but I want it to be 800px wide.

In many pages I have embedded images like this:

<img class="alignnone size-large wp-image-261" 
     width="600" height="456" />

I changed the size of large images in the media settings and regenerated the thumbnails. When I embed a new images into a post it works well. But all the old ones need to be updated.

I have too many pages to do it by hand. Is there an automatic way to do this?

  • A simple search of the forum will yield a number of duplicate questions and good answers. But in a nutshell images are resized on upload using the current settings, changing the settings does no resize images already in the media library. Use a plugin to regenerate the thumbnails that are already in your library. wordpress.org/plugins/…
    – Steve
    Sep 21, 2016 at 15:45
  • I searched WPSE and couldn't easily find a good answer @Stephen . If you re-read the question, the OP wants to replace the src attributes of image tags already embedded by the visual editor. Sep 21, 2016 at 16:04
  • The files are already regenerated. I need to change HTML code of my existing posts.
    – Jan
    Sep 21, 2016 at 17:20

2 Answers 2


So when you regenerated the thumbnails, did you use a plugin like: WordPress Regenerate Thumbnails plugin. Or did you make them in some other fashion? I've used this plugin before and it seemed to work for me.

Another possible way to do this is with making a style modification in your style.css file. You can overwrite the img.size-large style and force it to a particular width:

img.size-large { width: 600px !important; }

Doing this though might have unexpected results. Perhaps an image has inline styling and such. But it's worth a try.

Let us know if this worked or not.


  • 1
    The OP wants to know how to replace the HTML for images already embedded in the visual editor. Sep 21, 2016 at 16:03
  • Andy is right. I used Regenerate Thumbnails. The problem is, that the image size is hard coded in the HTML content of every post. Changing the size with CSS would not help. It would blow up the 600px version resulting in a blurry image.
    – Jan
    Sep 21, 2016 at 17:19

If all of the images are the exact same dimensions, you could do a mySQL query to replace the -600x400 portion with -800x600, width="600" with width="800", and height=400 width height=600.

If any of the image sizes vary, say you have some vertical images, you could use a mySQL query to do a search and replace regex. If you stripped all the images of the -600x456 (hyphen, 3 digits, x, 3 digits) portion as well as the width and height attributes, you would then be pulling the base image (which may or may not be what you want to pull).

Unless your images are identical, I don't think there is any way to automate the process. You could do a mySQL query to find all of the posts you need to change, but that's about as far as you can go with automation.

  • 1
    You could use the fact that the HTML contains the attachment ID, loop through posts and pages, scan the_content for images, use the attachment ID to look up the new file name and replace. Sep 21, 2016 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.