WordPress.org

Ready to get started?Download WordPress

Forums

static dimensions for uploaded original images (3 posts)

  1. warmbeer
    Member
    Posted 7 years ago #

    using wp 2.1.3

    okay, i've found a lot of postings, hack-suggestions and pretty cool plugins, but i'm in needs to find out which piece of code is writing the original files (images) from the upload-dialog.

    i just want to resize (imagecopyresized ?) the uploaded images to fixed maximum dimensions. do i have to change some code in the wp_handle_upload function?

    many thanks for any suggestions

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    So, you want it to resize the original images? Or are you talking about changing the size of the thumbnail images that it creates from the resizing?

    Right now, it doesn't do anything to the original images at all. You could probably hook the add_attachment action hook to get the post_id of the attachment, after it has been added. Then you could pull the image data from the post and do whatever resizing you like to the original image. You'd also need to update the width and height parameters in the attachment though.

    But no piece of code "writes" the original file. PHP handles that by itself. The wp_handle_uploads() function takes the upload and moves it to the right place. Then wp_insert_attachment() deals with all the rest of it for the database functions. If you really wanted, you could hook the wp_handle_upload filter to get the filename and type and such, and resize it there.

  3. warmbeer
    Member
    Posted 7 years ago #

    Thanks Otto,

    yes, all it is about is to resize the original images. The wp_handle_uploads doesn't seem to be the right file to be involved for this issue.

    I'll have a closer look to the wp_insert_attachment(), and if there are stil some questions left, i will continue this thread. otherwis i'll try to post my poor progressions here.

Topic Closed

This topic has been closed to new replies.

About this Topic