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
I have an issue with the Media Picker data type
It will select an image from the media files in the back office and display it.
However, in the front end, the image does not display. Inspecting the element I see this:
img src="1106" alt
the src is only displaying the id of the image, not the file path.
Also, how can I make it possible for the user to add a value to the alt?
Thanks in advance!
Hi,
If it's a single item media picker and you are using MVC then this is what you need to do:
@{ if (CurrentPage.HasValue("mainImage")){ var dynamicMediaItem = Umbraco.Media(CurrentPage.mainImage); <img src="@dynamicMediaItem.Url" alt="@dynamicMediaItem.Name"/> } }
Are you using Umbraco v6 or v7?
Jeavon
I'm using Umbraco V7
I have already in the template:
img src="@Umbraco.Field("sbPageGraphic")" alt="@Umbraco.Field("altText")" /
how do I integrate this with the code you gave me so that it will find the file path of the image and not just the id?
Hi Christine,
Just like this:
@{ if (CurrentPage.HasValue("sbPageGraphic")) { var dynamicMediaItem = Umbraco.Media(CurrentPage.sbPageGraphic); <img src="@dynamicMediaItem.Url" alt="@CurrentPage.altText" /> } }
Yes that did it - thanks so much!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Media Picker does not display image on front end
I have an issue with the Media Picker data type
It will select an image from the media files in the back office and display it.
However, in the front end, the image does not display. Inspecting the element I see this:
img src="1106" alt
the src is only displaying the id of the image, not the file path.
Also, how can I make it possible for the user to add a value to the alt?
Thanks in advance!
Hi,
If it's a single item media picker and you are using MVC then this is what you need to do:
Are you using Umbraco v6 or v7?
Jeavon
I'm using Umbraco V7
I have already in the template:
img src="@Umbraco.Field("sbPageGraphic")" alt="@Umbraco.Field("altText")" /
how do I integrate this with the code you gave me so that it will find the file path of the image and not just the id?
Thanks in advance!
Hi Christine,
Just like this:
Jeavon
Yes that did it - thanks so much!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.