Hi I am trying to get a site to work after having lost and recreated some of the source files, using the deployed site files. I have everything working on my local dev machine except for one thing: any image which is a media picker property does not display.
and I know this should work, as it does on the deployed site, but when I inspect the html the src url for the image is blank. This also happens if I omit the crop part of the url
I've tried rebuilding the indexes, publishing some items, but nothing has worked yet. I'm not sure where to look for the source of the problem.
var mediaItem = Umbraco.TypedMedia(Umbraco.AssignedContentItem.GetPropertyValue<int>("mainImage"));
var imageUrl = mediaItem.GetCropUrl("LargeSquare");
Also check that crop alias is exactly "LargeSquare", it's camel sensitive, so it is "largeSquare" will not work
all media urls do not work
Hi I am trying to get a site to work after having lost and recreated some of the source files, using the deployed site files. I have everything working on my local dev machine except for one thing: any image which is a media picker property does not display.
typically these are using
and I know this should work, as it does on the deployed site, but when I inspect the html the src url for the image is blank. This also happens if I omit the crop part of the url
I've tried rebuilding the indexes, publishing some items, but nothing has worked yet. I'm not sure where to look for the source of the problem.
Hi Jonny
Try to check what is in "CurrentPage.mainImage" property? Is there a valid media id?
Thanks,
Alex
yes there is a valid media id
also If I construct the url manually using the Id the image gets served.
the issue is just that @Umbraco.Media is not able to construct the url
Hi Jonny
Try this code:
Also check that crop alias is exactly "LargeSquare", it's camel sensitive, so it is "largeSquare" will not work
Thanks,
Alex
yes that works. but I've no idea why the other syntax, which works on my live site, does not work
is working on a reply...