Images uploading 2 copies
Hello everyone,
I have some questions. I have created a new image album named "Header Images" and uploaded 4 images. I then unpublished one image. When I get all the images from that album (and use ContentLIfeCycleStatus.Live) I get all 4 images.
Q1 - Shouldn't I only get the 3 that are published?
Also when I look at the sf_media_content table, I see 2 copies of each of the 4 images and the one that I unpublished is unpublished on one and not on both.
Q2 - Why are the images uploaded twice?
Q3 - Why don't both images that I unpublish actually unpublish?
Thank you for your help.
Tim Savage
Hello Rushman,
Here are answers to your questions:
Q1 - Shouldn't I only get the 3 that are published?
You can use predefined filters when query published images:
var publishedImages = App.WorkWith()
.Album(
new
Guid(
"4BA7AD46-F29B-4E65-BE17-9BF7CE5BA1FB"
))
//default album
.Images()
.Where(Telerik.Sitefinity.Modules.PredefinedFilters.PublishedItemsFilter<Telerik.Sitefinity.Libraries.Model.Image>());
Hi,
Thanks for the post this resolved my issue.
I was using code
List<Telerik.Sitefinity.Libraries.Model.Image> images = App.WorkWith().Images().Get()
.Where(i => i.Parent.Title == GalleryName && i.Status == ContentLifecycleStatus.Live).OrderBy(o => o.Ordinal) .ToList();
was expecting only published images though still it was returning unpublished images,
using above example I modified code and its returning only published images
List<Telerik.Sitefinity.Libraries.Model.Image> images = App.WorkWith().Images().Get()
.Where(i => i.Parent.Title == GalleryName)
.Where(Telerik.Sitefinity.Modules.PredefinedFilters.PublishedItemsFilter<Telerik.Sitefinity.Libraries.Model.Image>())
.OrderBy(o => o.Ordinal).ToList();