Media Preprocessing #17469
-
Hello everyone 👋 Does anyone know if there is a way to do sort of a preprocessing for media images being uploaded to a content item? We are using azure media storage to upload the users files into azure and then serve those from a can to a different custom module page later. We have some users uploading images that are on the larger side, and they're causing some issues down stream on that mvc page trying to load them from the cdn later on. We are looking into some options and are considering reformatting them to a potentially smaller size and/or in webp format. Putting a size restriction on upload could maybe work going forward but then it puts more burden on our users to resize the images so I don't think we're going to able to go down that road at this time. I think we'd rather do some processing on our side. There's other non orchard core options we might look into either like just processing them after the upload into a new file and having the front end reference that one. Thank you for any insight or ideas! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
If your only issue is that the images being served on the frontend are too large, then you can use Media Profiles to automatically resize them (as well as change their file format). This only affects how the files are served; still, the original files are stored. This is what I'd recommend. If you really want to resize images on upload, then you could hijack the file creation by implementing |
Beta Was this translation helpful? Give feedback.
-
That's extremely helpful, thank you for pointing me in that direction! |
Beta Was this translation helpful? Give feedback.
If your only issue is that the images being served on the frontend are too large, then you can use Media Profiles to automatically resize them (as well as change their file format). This only affects how the files are served; still, the original files are stored. This is what I'd recommend.
If you really want to resize images on upload, then you could hijack the file creation by implementing
IMediaCreatingEventHandler.MediaCreatingAsync()
.