So it's a mystery to me why the Media Picker suddenly returns a collection in Umbraco 7.5? I also had to explicitely define the type IPublishedContent because when I used the var keyword, then the type was not correctly inferred and the call:
imageUrl = image.GetCropUrl( 800, 600 );
did not work. Image then turnes out to be of type dynamic and the call GetCropUrl() throws an exception: 'Umbraco.Web.Models.PublishedContentWithKeyBase' does not contain a definition for 'GetCropUrl'
What is also strange is that the call image.GetPropertyValue( "umbracoWidth" ); returns a string now instead of an integer. Any idea why this is changed in Umbraco 7.5?
I found a solution for the media picker returning a collection. When I go the the Media Picker data type and I check the option, "Pick multiple items", save it, uncheck it and save it again then the media picker property won't return a collection but instead a single (dynamic) Umbraco.Web.Models.PublishedContentWithKeyBase which should be casted to IPublisheContent.
Problem fetching image in view in Umbraco 7.5
This code worked perfectly fine in Umbraco 7.3.
BannerBackgroundImage is of data type Media Picker.
In a clean Umbraco 7.5.4 install I get the following Exception (RuntimeBinderException).
'Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Id'
Umbraco.ModelsBuilder.Enable is set to false in the web.config.
How should I solve this?
Thanks! Gert.
Hi Gert,please try it
@if (CurrentPage.HasValue("BannerBackgroundImage")) {
Hi Carlu,
This didn't help, but the following did
So it's a mystery to me why the Media Picker suddenly returns a collection in Umbraco 7.5? I also had to explicitely define the type IPublishedContent because when I used the var keyword, then the type was not correctly inferred and the call:
did not work. Image then turnes out to be of type dynamic and the call GetCropUrl() throws an exception: 'Umbraco.Web.Models.PublishedContentWithKeyBase' does not contain a definition for 'GetCropUrl'
What is also strange is that the call image.GetPropertyValue( "umbracoWidth" ); returns a string now instead of an integer. Any idea why this is changed in Umbraco 7.5?
Regards, Gert.
Hi,
I found a solution for the media picker returning a collection. When I go the the Media Picker data type and I check the option, "Pick multiple items", save it, uncheck it and save it again then the media picker property won't return a collection but instead a single (dynamic) Umbraco.Web.Models.PublishedContentWithKeyBase which should be casted to IPublisheContent.
Cheers, Gert.
is working on a reply...