XWiki Platform
  1. XWiki Platform
  2. XWIKI-13524

Attachments are not copied from a Template Provider

    Details

    • Tests:
      Unit
    • Difficulty:
      Trivial
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      Create a Template Provider and a Template that used images (attachments) inside its content. Creating new pages using this Template will create new pages that have children, objects, etc. but they don't have the initial attachments.

        Issue Links

          Activity

          Hide
          Alex Cotiugă added a comment - - edited

          IMO, images from the template shouldn't be attached to all the pages created using it. Instead, the code should use always the image from the template and not from current page (e.g.: image:MySpace.MyTemplate@img.png instead of image:img.png)

          Show
          Alex Cotiugă added a comment - - edited IMO, images from the template shouldn't be attached to all the pages created using it. Instead, the code should use always the image from the template and not from current page (e.g.: image:MySpace.MyTemplate@img.png instead of image:img.png)
          Hide
          Ecaterina Moraru (Valica) added a comment -

          In this case (it was a placeholder image) let's say we could use the image from the template provider or (if we have internet connection) we could use an external placeholder image (like https://placeholdit.imgix.net/~text?txtsize=56&txt=Image&w=400&h=225 for example).

          Another use case would be if the image is used for layout. Maybe in this case templates are not ideal and we should use sheets/application entries instead.

          There is no use case when we want images copied to the template instances?

          Show
          Ecaterina Moraru (Valica) added a comment - In this case (it was a placeholder image) let's say we could use the image from the template provider or (if we have internet connection) we could use an external placeholder image (like https://placeholdit.imgix.net/~text?txtsize=56&txt=Image&w=400&h=225 for example). Another use case would be if the image is used for layout. Maybe in this case templates are not ideal and we should use sheets/application entries instead. There is no use case when we want images copied to the template instances?
          Hide
          Alex Cotiugă added a comment -

          When you have objects added to your new page created following a template, the objects are empty and get later information specific to the page. In the case of images, I guess you want the same image to be attached to more pages. I don't see the need of duplicating data.

          Show
          Alex Cotiugă added a comment - When you have objects added to your new page created following a template, the objects are empty and get later information specific to the page. In the case of images, I guess you want the same image to be attached to more pages. I don't see the need of duplicating data.
          Hide
          Alex Cotiugă added a comment -

          Something else that could be done for this is to attach the picture to the XWiki.TemplateProviderSheet.

          Show
          Alex Cotiugă added a comment - Something else that could be done for this is to attach the picture to the XWiki.TemplateProviderSheet.
          Show
          Vincent Massol added a comment - I think the code to be fixed is https://github.com/xwiki/xwiki-platform/blob/052a2a9cbb248c7aae893335e52c199d7db0ab02/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java#L3832L3853 and that code should also copy the attachments.
          Hide
          Anca Luca added a comment -

          I don't see the need of duplicating data.

          I think this can be interpreted in a different key as well: pages created from templates are supposed to be completely independent (from the templates) after creation and live their own life, not depending on the template anymore (and not having any connection to the template). Also, the idea of a template is that it's only a starting point for a document, and that the document can be modified in any way after (for images this would mean: add extra images, remove images, add new versions of the images, etc). This independence also says that a template should be deletable at any point and the pages created from that template will remain perfectly functional.
          IMO, to keep this independence of pages created from templates, by default the behaviour should be to copy the images (just like all other metadata is), and if the user wants to use only one set of images stored in a different page, they can create that separate page (probably different from the template) and put absolute references to it in the template.

          The mechanism more adapted for "centralizing" the control over the display of a set of pages is the mechanism of sheets (using a sheet for a set of documents) rather than templates, for which there is cohesion on all the points I described above and indeed, in that case, the approach would be to keep the images in a single place.

          Show
          Anca Luca added a comment - I don't see the need of duplicating data. I think this can be interpreted in a different key as well: pages created from templates are supposed to be completely independent (from the templates) after creation and live their own life, not depending on the template anymore (and not having any connection to the template). Also, the idea of a template is that it's only a starting point for a document, and that the document can be modified in any way after (for images this would mean: add extra images, remove images, add new versions of the images, etc). This independence also says that a template should be deletable at any point and the pages created from that template will remain perfectly functional. IMO, to keep this independence of pages created from templates, by default the behaviour should be to copy the images (just like all other metadata is), and if the user wants to use only one set of images stored in a different page, they can create that separate page (probably different from the template) and put absolute references to it in the template. The mechanism more adapted for "centralizing" the control over the display of a set of pages is the mechanism of sheets (using a sheet for a set of documents) rather than templates, for which there is cohesion on all the points I described above and indeed, in that case, the approach would be to keep the images in a single place.
          Hide
          Anca Luca added a comment -

          Something else that could be done for this is to attach the picture to the XWiki.TemplateProviderSheet.

          This is definitely not a good idea: attaching user content to a page from a default application (and customizing, thus, the default application) looks like a hack that we would use only because it works. Ideally user content should be stored in a page that is user content (created by the user in a user space, etc).

          Show
          Anca Luca added a comment - Something else that could be done for this is to attach the picture to the XWiki.TemplateProviderSheet. This is definitely not a good idea: attaching user content to a page from a default application (and customizing, thus, the default application) looks like a hack that we would use only because it works. Ideally user content should be stored in a page that is user content (created by the user in a user space, etc).
          Hide
          Thomas Mortagne added a comment -

          The point of the templates is to be duplicated, that's what they were designed for. There is no reason to duplicate everything but the attachments and developers should not have to worry about it.

          Show
          Thomas Mortagne added a comment - The point of the templates is to be duplicated, that's what they were designed for. There is no reason to duplicate everything but the attachments and developers should not have to worry about it.
          Hide
          Guillaume Delhumeau added a comment -

          I agree the current behavior is a problem for the reasons described by both Thomas and Anca.

          Show
          Guillaume Delhumeau added a comment - I agree the current behavior is a problem for the reasons described by both Thomas and Anca.

            People

            • Assignee:
              Eduard Moraru
              Reporter:
              Ecaterina Moraru (Valica)
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Date of First Response: