Resize images in existing posts

admin2025-01-07  3

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" 
     src="" 
     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?

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" 
     src="http://xxxxxxxxxx-600x456.jpg" 
     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?

Share Improve this question asked Sep 21, 2016 at 15:38 JanJan 1112 bronze badges 3
  • 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 Commented 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. – Andy Macaulay-Brook Commented Sep 21, 2016 at 16:04
  • The files are already regenerated. I need to change HTML code of my existing posts. – Jan Commented Sep 21, 2016 at 17:20
Add a comment  | 

2 Answers 2

Reset to default 0

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.

Chris

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736259673a606.html

最新回复(0)