I'd like to use GetCropUrl along with a MediaPicker. To be honest, I prefer the UI of the MediaPicker as it allows an already-uploaded image to be reused.
There are multiple ways to use the content in Umbraco and at a quick glance the, PublishedContentModels.Image reference looks like you are getting a Models Builder model returned rather than an IPublishedContent which also has the .GetCropUrl method.
I think you may have a mixture of approaches which is causing your problem.
What's your @inherits model at the top of your view?
I think I can point you in the right direction to investigate then:
Umbraco.Web.PublishedContentModels.Image is a generated class from ModelsBuilder which takes the 'Image' media type in your database and provides a strongly typed model for it. Look for a file Image.generated.cs to see the generated class (By default it will be in your App_Data folder).
Have a read of the ModelsBuilder documentation found in these posts which will explain further how the whole system works:
I suspect you might have the config for models builder in the default mode (PureLive from memory). Obviously, it's difficult to tell from one error without seeing the rest of your site, but I suspect you will need ModelsBuilder in a mode that produces a DLL that you can then reference from anywhere in your code.
GetCropUrl with MediaPicker
Hi,
I'd like to use GetCropUrl along with a MediaPicker. To be honest, I prefer the UI of the MediaPicker as it allows an already-uploaded image to be reused.
So, I've been following along with this https://umbraco.com/follow-us/blog-archive/2014/5/30/developing-a-website-with-responsive-images-using-the-umbraco-v714-image-cropper/
However, it doesn't seem to be working for me:
Gives me an error:
All I want to be able to do is pick an image through the media picker and then use GetCropUrl to generate different sizes in different views.
Any ideas?
Thanks
Simon
Hi Simon,
There are multiple ways to use the content in Umbraco and at a quick glance the,
PublishedContentModels.Image
reference looks like you are getting a Models Builder model returned rather than anIPublishedContent
which also has the.GetCropUrl
method.I think you may have a mixture of approaches which is causing your problem.
What's your
@inherits
model at the top of your view?Hi Matt,
It's:
Many thanks
Simon
Hi Simon,
I think I can point you in the right direction to investigate then:
Umbraco.Web.PublishedContentModels.Image
is a generated class from ModelsBuilder which takes the 'Image' media type in your database and provides a strongly typed model for it. Look for a fileImage.generated.cs
to see the generated class (By default it will be in your App_Data folder).Have a read of the ModelsBuilder documentation found in these posts which will explain further how the whole system works:
I suspect you might have the config for models builder in the default mode (
PureLive
from memory). Obviously, it's difficult to tell from one error without seeing the rest of your site, but I suspect you will need ModelsBuilder in a mode that produces a DLL that you can then reference from anywhere in your code.I hope this helps
Matt
is working on a reply...