What is the best way to get the URL to a media picker image in an Umbraco 9 macro? It seems like a pretty easy ask, but Umbraco docs are pretty frustrating to follow (as a designer who dabbles in coding). It seems like a pretty easy ask and I find that with each version of Umbraco they change up the way in which you do something this easy. Here is the code I am using with som eof my unssuccessful tries commented out (some of these worked in previous Umbraco versions)
@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage
@using Umbraco.Extensions
@{
var testName = Model.MacroParameters["cdsTestimonialName"];
var testTitle = Model.MacroParameters["cdsTestimonialTitle"];
var test = Model.MacroParameters["cdsTestimonial"];
var getTestPic = Model.MacroParameters["cdsTestimonialImg"].ToString();
@* var fileimg = Umbraco.Media(getBioPic); *@
@* var fileimg = Umbraco.TypedMedia(getBioPic); *@
@* var fileImg = Umbraco.Media(getBioPic);
var fileImgUrl = fileImg.Url; *@
<div class="cds-card-bio">
<div class="row g-5">
<div class="col-3">
<p>@getTestPic</p>
<img src="/need/the/image-url.jpg" class="img-fluid rounded-circle cds-shadow" alt="@testName - @testTitle">
</div>
<div class="col-9">
<h4 class="cds-m-0">@testName</h4>
<h5 class="cds-subheader">@testTitle</h5>
<p>@test</p>
</div>
</div>
</div>
}
Get the image picker image URL in a Macro
What is the best way to get the URL to a media picker image in an Umbraco 9 macro? It seems like a pretty easy ask, but Umbraco docs are pretty frustrating to follow (as a designer who dabbles in coding). It seems like a pretty easy ask and I find that with each version of Umbraco they change up the way in which you do something this easy. Here is the code I am using with som eof my unssuccessful tries commented out (some of these worked in previous Umbraco versions)
For anyone wondering, I solved this using:
Nice thanks so much, I tried everything else using UmbracoHelpers and Umbraco.Content() and didnt work, so it must be a new implementation.
is working on a reply...