Testing image crops existence with Razor in Umbraco
I have created some Razor code to output images onto a page if the exist. It is detailed below and contains some simple checks to prevent rendering a blank list item. The site has gone live and works fine. The client then deleted the image from the media folder within Umbraco, meaning my node had a valid image assigned but the image just didn't exists. I got the following exception:
'string' does not contain a definition for 'crops'
Thanks for the feedback Dave but that was my post! I was struggling with actually using the image cropper in Razor but got it working in the end. Your comment about the helper method only seemed relevant for previous versions of Umbraco Razor where dynamic nodes were not returned. Is that right or would your technique still work?
Testing image crops existence with Razor in Umbraco
I have created some Razor code to output images onto a page if the exist. It is detailed below and contains some simple checks to prevent rendering a blank list item. The site has gone live and works fine. The client then deleted the image from the media folder within Umbraco, meaning my node had a valid image assigned but the image just didn't exists. I got the following exception:
'string' does not contain a definition for 'crops'
How do I deal with this?
Hi Jon,
Maybe this post can help you ?
http://our.umbraco.org/forum/developers/razor/25264-Finding-Image-Crops-using-Razor
Dave
Dave,
Thanks for the feedback Dave but that was my post! I was struggling with actually using the image cropper in Razor but got it working in the end. Your comment about the helper method only seemed relevant for previous versions of Umbraco Razor where dynamic nodes were not returned. Is that right or would your technique still work?
Hi Jon,
I'm using this code in a 4.7.1 version of Umbraco and it works there.
Dave
is working on a reply...