Just for your informatio we are using Umbraco 7.2.1 version and also WebForms rendering technique and not the MVC. My question to you is will the code snippet share by you will work fine in my case?
Yes as far as I remember you can also using Razor directly into your template when you are running in WebForm mode. Otherwise you can create a partial view macro, and insert this there where you want the logo to appear
When using webforms you need to create a partial view macro, which can be inserted in the template. You won't be able to execute the Razor code directly in the masterpage as you could with MVC.
As far as creation of partial view macro is concerened i am not at all ware of MVC coding. Is there some other technique like creating a user control and embeding some code in the user control to render this image? If yes please share that code snippet?
Adding Images To Templates From Media Folder
Hi All,
Can anyone please let us know the technique for uploading images to the templates from image already uploaded in Media folder.
Here is the technique we have applied so far :-
Can anyone please help us on this?
Regards
Tarunjit Singh
Hi Trunjit
You should use Razor to render the image - I don't think the above snippet works in v7. Does it return anything? A path or an id?
Otherwise you should be able to use Razor for this like this
You can read more about it here https://our.umbraco.org/documentation/Reference/Templating/Mvc/querying
I hope this helps.
/Jan
Hi Trunjit,
If you are using the media picker to selected the image in Umbraco backoffice, then you sould be good with this code.
See the documentation here. https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Media-Picker
Hope this helps,
/Dennis
Hi Jan,
Thanks for your reply.
But this doesn't seem to work. We have used following code snippet
var mediaId = Model.Umbraco.Field("logo").ToString();
<img src="@Model.Umbraco.TypedMedia(mediaId).Url" alt="" />
Just for your informatio we are using Umbraco 7.2.1 version and also WebForms rendering technique and not the MVC.
Regards
Tarunjit Singh
Hi Dennis,
Thanks for the help.
Just for your informatio we are using Umbraco 7.2.1 version and also WebForms rendering technique and not the MVC. My question to you is will the code snippet share by you will work fine in my case?
Regards
Tarunjit Singh
Hi Tarunjit,
Yes as far as I remember you can also using Razor directly into your template when you are running in WebForm mode. Otherwise you can create a partial view macro, and insert this there where you want the logo to appear
Hope this helps,
/Dennis
Hi guys
When using webforms you need to create a partial view macro, which can be inserted in the template. You won't be able to execute the Razor code directly in the masterpage as you could with MVC.
/Jan
Hi Dennis,
We have just tried your code snippet and it is not working. It is simply displaying the code snippet which we have written in template.
@if (CurrentPage.HasValue("logo")){
var dynamicMediaItem = Umbraco.Media(CurrentPage.yourimageproperty);
<img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/>
}
As far as creation of partial view macro is concerened i am not at all ware of MVC coding. Is there some other technique like creating a user control and embeding some code in the user control to render this image? If yes please share that code snippet?
Regards
Tarunjit Singh
Hi Tarunjit,
Create a partial view macro and insert the macro into the template. Try to see this documentation, on how to create partial view macro. https://our.umbraco.org/documentation/Reference/Templating/Macros/Partial-View-Macros/ and if you have access to the Umbraco TV take a look here: http://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/macros/creating-a-macro/
Hope this helps,
/Dennis
is working on a reply...