@Dan I'm using the cropper as a "Main" image in the media type .. so when you do media.url in a normal upload field it will read the "umbracoFile" property.
in this situation, the cropper save a json with all the options... e.g.
I need to get the image src at this point using a IMedia and later I need to get the image src from an IPublishedContent becuase I'm creating a model for my "image" item.
For IPublishedContent I would probably not use the DataValue but get the property value as a string as there are a few additional checks in there but the result would be the same.
How to get the source image from ImageCropper
Hi there,
I'm using the imageCropper and I couldn't figure out how to get the source image, is there any to way to get it without using the json....
e.g.
I need to get the src using "IMedia" and "IPublishedContent" is it possible ?? ... any ideas ?
Thanks,
Ale.
Hi Ale,
The source image should be available from the
media.Url
property if your media variable is of typeIPublishedContent
.Hope that helps.
Thanks, Dan.
UmbracoHelper.TypedMedia
orUmbracoHelper.Media
?I am not sure if I understand your question ;-)
For IMedia you will need to something like this (assuming "media" is IMedia)
@Dan I'm using the cropper as a "Main" image in the media type .. so when you do media.url in a normal upload field it will read the "umbracoFile" property.
in this situation, the cropper save a json with all the options... e.g.
so media.url will throw an exeption.
@Tobias I'm hooking in to ther saving event ... so at that point what I got is a list of IMedia.
private void MediaService_Saved(IMediaService sender, SaveEventArgs<IMedia> e)
I need to get the image src at this point using a IMedia and later I need to get the image src from an IPublishedContent becuase I'm creating a model for my "image" item.
does that make sense ??
Thanks for you awesome response time :)
Ale.
Actually you use that same method with with IPublishedContent to get the original source of the image from any Cropper Json data.
@jeavon yes, seems like this is the only way to do it is using the json...
from and IPublishedContent you can do "media.GetProperty("upload").DataValue;".
Would be great to keep the src apart of the json, this could be useful sometimes.
Thanks!
Ale.
Yes it is the only way.
For IPublishedContent I would probably not use the DataValue but get the property value as a string as there are a few additional checks in there but the result would be the same.
e.g.
Still looking for a solution for this problem.
is working on a reply...