Sorry for this very basic question but I have searched around and cannot seem to find an example that works for me.
I have a website where I want the client to be able to add an image of any staff they may have, however, if they do not have one I would like it to by default add a placeholder image rather than none at all.
I have figured out how to ignore a blank image and display nothing which I have as
But to get it to default to an image if one isn't selected I struggle with. I have tried the code below but it errors with
"The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])' "
If your default image will always be the same, ie nobody will want to change it, would suggest create a div and serve it as a background image via css.
If someone may want to change it at some point, put it in Umbraco on your "site" tab and call it from there as per the "aboutLeftImage".
Reason it's not working is that aboutLeftImage is in the Umbraco environment and images/default.png is in the root of the site, so without direction to get there, it cannot find it.
If the image path was just wrong he wouldn't be getting a .NET error. What gary is saying is right though, you will probably want your image path to have a leading /.
<img src="/images/default.png" />
The error looks like a datatype mismatch. Umbraco.Media() expects an int. You need to convert your value to an int. The easiest way would probably be to just cast it like this:
If Else statement
Hi All
Sorry for this very basic question but I have searched around and cannot seem to find an example that works for me.
I have a website where I want the client to be able to add an image of any staff they may have, however, if they do not have one I would like it to by default add a placeholder image rather than none at all.
I have figured out how to ignore a blank image and display nothing which I have as
But to get it to default to an image if one isn't selected I struggle with. I have tried the code below but it errors with
"The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])' "
Any suggestions or pointers would be gratefully received.
Thanks
Ben
Hi BEWD
If your default image will always be the same, ie nobody will want to change it, would suggest create a div and serve it as a background image via css.
If someone may want to change it at some point, put it in Umbraco on your "site" tab and call it from there as per the "aboutLeftImage".
Reason it's not working is that aboutLeftImage is in the Umbraco environment and images/default.png is in the root of the site, so without direction to get there, it cannot find it.
Hope that makes sense and helps you move forward.
Please ask again if you need anything more.
Regards
Gary
If the image path was just wrong he wouldn't be getting a .NET error. What gary is saying is right though, you will probably want your image path to have a leading /.
The error looks like a datatype mismatch. Umbraco.Media() expects an int. You need to convert your value to an int. The easiest way would probably be to just cast it like this:
Thanks guys, I cant believe it was all down to a missing /
Just adding that in has fixed the issue, I cant believe I missed that.
Thanks for your help and apologies for wasting your time :)
is working on a reply...