Multiple Media Pickers with 1 to 1 mapping to respective croppers
Hi Folks,
I was wondering if we can create multiple Media pickers which maps to specific Image Croppers. I am working on a project wherein I am trying to segregate the whole Architecture to be components based.
For Example
Let us assume I have a "Media Picker for Icons upload / selection from a specific Media folder with Icon MediaCroppers setup for it". Can this use case be achieved in any way?. Similarly I am planning up for other regions of the site.
Can I play around with Custom Media Types for each of the Media Picker mapped to specific Image Cropper?
I think you can in effect achieve what you are after as an example icons would need to live in a designated media folder prescribed using the umbraco 'structure' rules to only allow your icon media type. Your media picker would need to have the icon media folder as its start node.
You would then register a handler for the mediaservice.saving or saved event (can't remember which one i used). In the function you would check if this is a new entity and if the folder being uploaded to (its parent) is the icon folder you would chang the media type from image (default) to your icon media type. Then you know all media items for this picker will have the crop you want
I started trying your approach. I am not that familiar with Umbraco Services. It would be great to know how I can compare the current saving images folder with the parent folder on which the media saving was invoked.
I am able to hook into MediaService Saving and get the SavedEntities as well. Now the major concern is how I will figure out where this service was invoked if its only for "Icon Media Picker" or not. If its from "Icon Media Picker" then how will I be able to map that to already created "Icon Media Type" on the fly by using its alias.
Ill get you a copy of my code tomorrow. In the meantime the important thing to note is that in the mediaservice save event you wont make a direct reference to the picker itself at all. What you do is grab the save entity parent property and check if the media type alias of this parent equals iconfolder for example and then changecontenttype to your desired type using the alias eg "icon" as the argument. Where the picker comes in is that as you've set the start node to your icon folder you know that any image uploaded when using that picker is going to end up in the icon folder.
Multiple Media Pickers with 1 to 1 mapping to respective croppers
Hi Folks,
I was wondering if we can create multiple Media pickers which maps to specific Image Croppers. I am working on a project wherein I am trying to segregate the whole Architecture to be components based.
For Example Let us assume I have a "Media Picker for Icons upload / selection from a specific Media folder with Icon MediaCroppers setup for it". Can this use case be achieved in any way?. Similarly I am planning up for other regions of the site.
Can I play around with Custom Media Types for each of the Media Picker mapped to specific Image Cropper?
Please guide me, Thanks in Advance.
Thanks, Arun P K
I think you can in effect achieve what you are after as an example icons would need to live in a designated media folder prescribed using the umbraco 'structure' rules to only allow your icon media type. Your media picker would need to have the icon media folder as its start node.
You would then register a handler for the mediaservice.saving or saved event (can't remember which one i used). In the function you would check if this is a new entity and if the folder being uploaded to (its parent) is the icon folder you would chang the media type from image (default) to your icon media type. Then you know all media items for this picker will have the crop you want
Hi Ian,
First of all thanks for replying quickly.
I started trying your approach. I am not that familiar with Umbraco Services. It would be great to know how I can compare the current saving images folder with the parent folder on which the media saving was invoked.
I am able to hook into MediaService Saving and get the SavedEntities as well. Now the major concern is how I will figure out where this service was invoked if its only for "Icon Media Picker" or not. If its from "Icon Media Picker" then how will I be able to map that to already created "Icon Media Type" on the fly by using its alias.
Thanks in Advance.
Arun P K
Ill get you a copy of my code tomorrow. In the meantime the important thing to note is that in the mediaservice save event you wont make a direct reference to the picker itself at all. What you do is grab the save entity parent property and check if the media type alias of this parent equals iconfolder for example and then changecontenttype to your desired type using the alias eg "icon" as the argument. Where the picker comes in is that as you've set the start node to your icon folder you know that any image uploaded when using that picker is going to end up in the icon folder.
Hope that makes sense
this is my code
Hi Ian,
Thanks a lot pal, I was able to get it working. Now I am confident enough to play around with Media Picker, Image Croppers and Media Types.
Your Guidance helped me out to understand things pretty fast. Thanks a lot once again :).
Thanks,
Arun P K
is working on a reply...