I have a listing page I want to pick up the image from the block editor which I am using as a header section on the top of every page.
I have the following code
@if (child.HasValue("blocks"))
{
var childBlocks = child.Value<IEnumerable<BlockListItem>>("blocks").Take(1);
var test = child.Name;
foreach (var block in childBlocks)
{
var content = block.Content;
var settings = block.Settings;
var myimageUrl = "";
if (settings.Value("Image") != null)
{
myimageUrl = settings.Value<IPublishedContent>("Image").Url();
}
if (myimageUrl != "")
{
<img src="@myimageUrl" alt="@child.Name" />
}
Which pretty much picks up the image and outputs it on the listing page. However when I update the image on the page its still picking up the old image - any ideas how to always pick up the latest image?
I think this is a bit of a bug, but I bet you could work around it like this:
var myImage = settings.Value<IPublishedContent>("Image");
// get the picked image 'again' from cache
var myPossiblyUpdatedImage = Umbraco.Media(myImage.Id);
myImageUrl = myPossiblyUpdatedImage.Url();
Block Editor
I have a listing page I want to pick up the image from the block editor which I am using as a header section on the top of every page.
I have the following code
Which pretty much picks up the image and outputs it on the listing page. However when I update the image on the page its still picking up the old image - any ideas how to always pick up the latest image?
Or a better way to do this?
Hi Lori
I think this is a bit of a bug, but I bet you could work around it like this:
be interested to know if that works for you?
regards
Marc
is working on a reply...