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 apologize in advance for the very basic question.... How do you get an image url from a partial view macro?
I found code to return a URL with inline Razor code, but i couldn't get it to work when I tried to make it into a macro?
Thank you in advance
Using Umbraco 7 (Very new to everything about CMS and programming)
Hi Robert and welcome to our :)
If you're using Umbraco 7.1.1 you should use the new image cropper as described in the documentation here http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper - Make sure you read it thoroughly then it should be fairly easy :)
There is also a free video sample about getting images here http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals/razor-recipes/gallery/
Hope this helps - Otherwise let us know.
/Jan
Jan,
Thank you. I appreciate the quick reply
Hi Robert
You're welcome - please let us know if it works out for you :)
I found that a lot of the examples are for more complex galleries or multiple images. I had a media picker and just wanted to render a single image.
This works:
@{
if(Model.Content.HasValue("myImage")){
var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("myImage"));
<img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
}
Morgan and Jan,
Thank you both for your help.
The code worked... but how can I pass the document type property to the macro?
Again thank you.
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
How to get the url of an image in partial view macro
I apologize in advance for the very basic question.... How do you get an image url from a partial view macro?
I found code to return a URL with inline Razor code, but i couldn't get it to work when I tried to make it into a macro?
Thank you in advance
Using Umbraco 7 (Very new to everything about CMS and programming)
Hi Robert and welcome to our :)
If you're using Umbraco 7.1.1 you should use the new image cropper as described in the documentation here http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper - Make sure you read it thoroughly then it should be fairly easy :)
There is also a free video sample about getting images here http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals/razor-recipes/gallery/
Hope this helps - Otherwise let us know.
/Jan
Jan,
Thank you. I appreciate the quick reply
Hi Robert
You're welcome - please let us know if it works out for you :)
/Jan
I found that a lot of the examples are for more complex galleries or multiple images. I had a media picker and just wanted to render a single image.
This works:
@{
if(Model.Content.HasValue("myImage")){
var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("myImage"));
<img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
}
}
Morgan and Jan,
Thank you both for your help.
The code worked... but how can I pass the document type property to the macro?
Again thank you.
Morgan and Jan,
Thank you both for your help.
The code worked... but how can I pass the document type property to the macro?
Again thank you.
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.