Change the generated filename for resized media?

default discord avatar
reepicheep05last year
3

I am working on setting up a CDN for my media uploads and have set up the uploads collection with various sizes. I have removed the height attribute so that the images preserve their aspect ratio.



The generated files each have a different filename pattern. For example

filename-1200x374.jpg

and

filename-1200x854.jpg



I would like to change the filename to only include the width like

filename-1200.jpg

so that I can generate the correct srcset for each image from the filename string.



Is there a way to do this? Thanks!

  • discord user avatar
    denolfe
    last year

    Currently, it is not possible to customize the appending of the dimensions to the filename.

  • default discord avatar
    reepicheep05last year

    Ok thank you for the response. I have found another solution that does not require generating the URL. But I believe this would be a value addition at some point in the future.

  • default discord avatar
    richie3739 months ago

    Hey @reepicheep05 what workaround did you find?



    I got mine working now, but I don't know if it's much of a fix, because I had to delete all of the collections in Mongodb except for the one's payload adds in automatically (payload-migrations and payload-preferences) and then i had to make all new collections. I just copied the ones from this video by James (the repo is in the description) =>

    https://www.youtube.com/watch?v=bxWsZTtqs80&list=PLjy3Q_oHlvcx_jtUDtGc7xWNsp9gZdm1d

    Then from there I was just able to copy and paste a bunch of stuff into the new collections, and everything was working fine again.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.