WordPress.org

Ready to get started?Download WordPress

Forums

Change the generated image names (3 posts)

  1. robahas
    Member
    Posted 1 year ago #

    Hi - I am using the wp default image sizes to grab three different files of each image and use them in a gallery (hover on thumbnail to view medium, click on medium to see large). I was hoping to just upload any old image and then after WP create the different sizes and I could just grab them dynamically by appending the size to the file name. So:

    Large = image-name.jpg
    thumbnail = image-name-70x70.jpg
    medium = image-name-500x340.jpg

    But since the media uploader defines MAX size, images will not re-size to the exact dimensions (which is exactly what I want). The problem is that the medium file name changes due to this. if the image is re-sized to 500x330, that is reflected in the image name. Since I have no way of predicting this, I can't count on it to call up the file name.

    It would be nice if I could just have the file names generate as:

    large = image-name.jpg
    thumb = image-name-thumnail.jpg
    medium = image-name-medium.jpg

    Any ideas on this?

    Thanks in advance

  2. bcworkz
    Member
    Posted 1 year ago #

    You can display the image by it's general size specification and the attachment ID with:wp_get_attachment_image($id, 'medium'); or wp_get_attachment_image($id, 'large');

    If you need an image of a specific size, you can use the WP_Image_Editor.

  3. robahas
    Member
    Posted 1 year ago #

    Thanks. Very useful!

Topic Closed

This topic has been closed to new replies.

About this Topic