Support » Plugins » Hacks » Change the generated image names

  • 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-70×70.jpg
    medium = image-name-500×340.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 500×330, 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    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.

    Thanks. Very useful!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change the generated image names’ is closed to new replies.