• By default, the media library loads the Medium image size defined in Settings> media. I would like to set it to one of my theme post thumbnail sizes. Is there a filter for changing which size is loaded?

    Thank you

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

    (@bcworkz)

    Huh. My browser defaults to the last selected size. I nearly always use the same size so I rarely need to change this field. Anyway, the media library is javascript based, so I’d be surprised if there is a PHP filter for this.

    You could add a small jQuery script that sets the form element to the thumbnail size regardless of what the user did last.

    Thread Starter ndh01

    (@ndh01)

    Hi bcworkz,

    You may be referring to form dropdown under ATTACHMENT DISPLAY SETTINGS?

    I’m interested in the image size that WordPress uses when displaying the grid of images either in the admin menu for Media or when inserting the post. If you right click and inspect the images, it is pulling the Medium image size that is defined in Settings – Media. If you don’t have a Medium size defined, it will use the full size images.

    Moderator bcworkz

    (@bcworkz)

    Ah, OK, I think I see now.

    It appears that same image is used to generate the thumbnails in the grid, just downsized. So you would be focusing on code where the media grid is displayed, not the Attachment Details modal, as that is just reusing the same image loaded for the grid, downsized less.

    I wasn’t able to find a specific filter for these images, but I had trouble following the code, it’s still mostly javascript. It appears the image URLs come through the ‘wp_get_attachment_url’ filter, but there is no way to know what request is for the image grid and a request for anything else.

    If you could find a hook that fires before and after the image loading, you could add, then remove the attachment URL filter to ensure it only is used on grid images, but I was unable to find suitable hooks. Perhaps someone with more experience or patience than I could find a way, but I’m not seeing any, sorry.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filter for Media Library to load different image size other than medium’ is closed to new replies.