1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Deleting Images and Documents

Deleting Images and Documents

4 posts, 0 answered
  1. SolarX
    SolarX avatar
    14 posts
    Registered:
    24 Oct 2006
    01 Jul 2010
    Link to this post
    Hello,

    I have allowVersioning="True" and allowWorkflow="True" for the "Libraries" module.

    If an image is used in a page, I would expect that you can't just delete it from the library leaving the page with a broken link. But as far as I've tested, you can just do that...delete an image with no approval and publish workflow. There also seems to be no rollback and history...

    For our purpose an image or document should never be just deleted if they are used in the content of pages. This would allow our editing employees to produce broken links in pages without even noticing it at first.

    Could someone please help me with that?

    Rgards
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Jul 2010
    Link to this post
    Hi SolarX,

    Libraries module does not support versioning. If you use Iamge Gallery or Image control on a page the image will be removed and you will not have a broken link. You can have broken link only in case you use GenericContent control where the image url is added as HTML.

    It is quite difficult to detect whether you have a link to an image declared in a GenericContent control.

    1. You have to create a custom web service with a delete method inside it.

    2. You have to map the external template for LibraryItemsView.ascx How to map a template and replace the built-in web service.

    3. Inside the del;ete method you need to find all generic content controls using the code below, get the content of each instance and check the sfref attribute of img tag which will return the ID of the Item, so you will know whether you are trying to delete this image.

    Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
    IList list = cmsManager.GetPages()
    foreach (ICmsPage currentPage in list)
    {
        if (currentPage != null)
        {
            IList<Telerik.Cms.ICmsWebControl> pageControls = currentPage.Staged.Controls;
            foreach (Telerik.Cms.ICmsWebControl webCtrl in pageControls)
            {
                if (webCtrl.ControlType == typeof(Telerik.Cms.Engine.WebControls.GenericContent))
                {
                    Telerik.Cms.Engine.WebControls.GenericContent gcCtrl = webCtrl.LoadControl() as Telerik.Cms.Engine.WebControls.GenericContent;
                    var cnt = gcCtrl.Content
                }
            }
        }
    }


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. SolarX
    SolarX avatar
    14 posts
    Registered:
    24 Oct 2006
    01 Jul 2010
    Link to this post
    Hi Ivan,

    I've just followed you advice and used the image control instead of embedding the image via WYSIWYG editor in a generic content.
    But if I delete the image from the library, it is also lost in the image-control on the page and I have a broken link (red cross)...
    Am I doing something wrong ?

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Jul 2010
    Link to this post
    Hello SolarX,

    Ok, the image is removed only for the ImageGallery control, because it is databound control. So , the only solution for now is the same as described.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered