Images uploading 2 copies

Posted by Community Admin on 03-Aug-2018 01:28

Images uploading 2 copies

All Replies

Posted by Community Admin on 17-Mar-2011 00:00

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

Posted by Community Admin on 18-Mar-2011 00:00

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>());


Q2 - Why are the images uploaded twice?

Q3 - Why don't both images that I unpublish actually unpublish?


The binary data about an image is uploaded at separate table sf_chunks.  Internal implementation of content lifecycle suppose more than one record at database for a content item and it is organized like this:

For a content item depending on the different content statuses it goes through, different records are maintained at database. A content item always has master record which is the primary state of an item (at table sf_media_content the row with status = 0) and it is not visible at UI. When you unpublish an record there is one master record and one record in status draft.

More details about managing content life cycle see user and developer guide:

http://www.sitefinity.com/documentation/user-guide/managing-the-status-of-content-items-and-pages/managing-a-page-or-content-item-that-is-published.aspx

http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-modules-content-lifecycle.html


Best wishes,
Milena
the Telerik team

Posted by Community Admin on 25-Nov-2013 00:00

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();

This thread is closed