How to get the URL and Name of the existing image.
Hi,
I am trying to upload the image dynamically to the sitefinity library. But every time i upload the same image, its getting upload into the library with the modified name, but i don't want to upload the image if it is already there in library.
Is their any way to check weather the image with the same name is there in Library or not. and if it is present in the library i want to get its URL.
Please clarify.
Thanks & Regards,
Harish
Hi Harish,
You can easily check for an existing image using our Images API like this:
var imageToCheck = App.WorkWith()
.Images()
.Where(i => i.UrlName ==
"urlname to check"
&& i.Status== Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
.Get()
.FirstOrDefault();
if
(imageToCheck !=
null
)
var imageUrl = imageToCheck.Urls.Where(u => u.RedirectToDefault ==
false
).FirstOrDefault().Url;