I am looping through media folder with certain Id to display images. I deleted some of images from there and I don't see them in back office, but I still get them while looping, it acts like they are still there. Here is the code:
var media = Umbraco.Media(1472);
@foreach (var file in media.Children)
{
var ImageId = Umbraco.Media(file.Id);
var Image = ImageId.UmbracoFile;
<img src="@Image" class="lightbox-image "/>
}
In variable "Image" there are still deleted files Url's. Since they're deleted It renders on my page as "Url not found". Why is it doing it? How can I really delete something from folder, or how to display only items that aren't deleted.
This shouldnt have any relation to this. You can add file and delete them in Umbraco media section. Adding works fine, but deleting doesnt. File is deleted and not there but looping still returns url for example /media/1024/image5.jpg even tough theres nothing there
This returns the error:
cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
I tried this:
@foreach (var file in media.Children.Where("Visible"))
var media = Umbraco.TypedMedia(1089).Children.OfTypes("Image").Where(x => x != null);
@foreach (var img in media)
{
<img src="@img.Url" class="lightbox-image" />
}
Also in your Developer Section, check the XML Cache integrity for the Media Items.
It does not. It's not null, Umbraco doesn't delete meta data. So I can even get height, type, all the information about deleted file. Bascially everything is kept except file itself.
That's not null, that returns that url. I switched to another approach that I don't like very much, but it works. Instead of looping through folder, I made API where user needs to select all images himself through Multi Media Picker. That works but it's not what I wanted. I dunno why Umbraco acts the way he does and keeps all meta data.
I am sorry I don't understand. I don't see media in developer's tab, and unfortuanatly don't know what examine indexes are. Can you elaborate so I can rebuild them. But if you ask do I see media in Media section I don't.
Deleted Media still showing
I am looping through media folder with certain Id to display images. I deleted some of images from there and I don't see them in back office, but I still get them while looping, it acts like they are still there. Here is the code:
In variable "Image" there are still deleted files Url's. Since they're deleted It renders on my page as "Url not found". Why is it doing it? How can I really delete something from folder, or how to display only items that aren't deleted.
Is it that they are in the bin, so unpublished and not in the main media folder?
This shouldnt have any relation to this. You can add file and delete them in Umbraco media section. Adding works fine, but deleting doesnt. File is deleted and not there but looping still returns url for example /media/1024/image5.jpg even tough theres nothing there
Try something like this
This returns the error:
cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
I tried this:
@foreach (var file in media.Children.Where("Visible"))
But didn't solve my issue
But this:
Returns false for all files. Nothing is published, because it's in media section and there's not publish button there
Something like this should do it
Also in your Developer Section, check the XML Cache integrity for the Media Items.
It does not. It's not null, Umbraco doesn't delete meta data. So I can even get height, type, all the information about deleted file. Bascially everything is kept except file itself.
Not too sure but I reckon you can check if the file inside the media element is != null (I think is called
umbracoFile
) or the url is nullThat's my question actually, I dunno how to check is it null, because url itself isn't. I get /media/1024/image5.jpg for example.
is
.GetPropertyValue("umbracoFile") == null
?That's not null, that returns that url. I switched to another approach that I don't like very much, but it works. Instead of looping through folder, I made API where user needs to select all images himself through Multi Media Picker. That works but it's not what I wanted. I dunno why Umbraco acts the way he does and keeps all meta data.
What version of umbraco are you running?
7.4.3
Hi Anamarija,
I got hit by this too... it's a bug, fixed in Umbraco v7.5.5
http://issues.umbraco.org/issue/U4-9137
If you can't upgrade, then the best you can do is to check the media node's
Path
, see if it starts with"-1,-21,"
.Cheers,
- Lee
Thank you!
Sounds like your examine indexes are not up to date.
If you search for the media items in the develop tab, can you still find this image? which you are referring? If so, rebuild the index.
I am sorry I don't understand. I don't see media in developer's tab, and unfortuanatly don't know what examine indexes are. Can you elaborate so I can rebuild them. But if you ask do I see media in Media section I don't.
I just had this same issue running 7.6.1. Tried everything, then found this article and an Examine re-index fixed it.
Hi Guys
Anyone having trouble with Umbraco 8. Here is how I do it.
is working on a reply...