0

I'm using WpeMatico plugin which saves images in the post using:

$attach_id = wp_insert_attachment( $attachment, $filename, $postid );

I looked inside wp-includes/post.php > wp_insert_attachment function, but couldn't quite figure how to resize images. I want ALL/ANY images to have a max size of 1024 resize proportionately. I also have the resizing function, just not sure how to use it.

Thanks!

1 Answer 1

2

The original image size (i.e. 'full') is never modified. Intermediate image sizes are controlled in various places:

  1. Default image sizes ( 'thumbnail', 'medium', 'large' ): core settings, via Dashboard -> Settings -> Media
  2. Custom image sizes: Theme functions.php file, via add_image_size()
  3. Post Thumbnail size ( 'thumbnail' ): Theme functions.php file, viaset_post_thumbnail_size()`

By default, the 'large' image size is constrained to 1024px. So, you can simply output this image size where you need a 1024px image.

If you need to create a custom image size, you'll just need to regenerate thumbnails for existing images.

Edit

If you need/want to constrain the size of the 'full' image size, then you'll need to modify it during the upload process, i.e. by hooking into wp_handle_upload, and performing the resize.

There are various Plugins that accomplish this. A quick search turns up:

4
  • All the options you mentioned resize the image only for DISPLAY, they don't actually "resize" the image to those dimensions, right? I want to resize the image on upload to reduce file size.
    – Nimbuz
    Commented May 14, 2012 at 16:53
  • See edited answer. Commented May 14, 2012 at 17:15
  • Thanks, but again, those plugins won't help me because WpeMatico is uploading those images programmatically, I'm not uploading them manually myself so I could use those plugins.
    – Nimbuz
    Commented May 14, 2012 at 17:21
  • Use a different Plugin, then? Or just use the core UI for image attachments? Commented May 14, 2012 at 18:41

Your Answer

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

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