Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
Try to check what is in "CurrentPage.mainImage" property? Is there a valid media id?
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
Try this code:
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
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...
Write your reply to:
Image will be uploaded when post is submitted