# Create a description field for page attachments

**URL:** <https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346>\
**Category:** Development\
**Tags:** proposal\
**Created:** [March 28, 2024, 12:29pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346 "2024-03-28T12:29:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjeanjean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/pjeanjean/32/5901_2.png) [@pjeanjean](https://forum.xwiki.org/u/pjeanjean)\
**Post date:** [March 28, 2024, 12:29pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/1 "2024-03-28T12:29:23Z")

</div>

Hello everyone,

I am currently working on [Loading...](https://jira.xwiki.org/browse/XWIKI-21938) and would like some feedback for a few points.  
To sum up, attachment revisions stored in the database currently have a field `XWA_COMMENT` that is not used anywhere. The idea would be to add a setting to expose this field to provide a way to upload one or multiple attachments with a comment, and display it both on the list of attachments and the revision history for attachments. Here is a mock-up from the issue for when the setting is enabled:

 ![image](https://forum.xwiki.org/uploads/default/original/2X/d/d23243430e78e0643b6b9c2b738b7a7a7964a30e.png)

Now, the field mentions a comment, the issue asks for a description, and in essence the feature is very close to the concept of revision summaries we already have for documents. So a first question would be: how should we name this feature?  
Personally, I would be +1 to use “summary” since it would be more aligned to the current UI, but I’m open to other ideas.

Also, note that the current limit on the field is 1023 characters, which seems enough to me for this feature so I would keep it as is.

Finally, where exactly should this be displayed and how should it be edited? The issue mentions only that the field should be set during upload and displayed in the attachments list and the attachments history. If we consider this as a summary, I think it would make sense to have a default value for the different upload methods (upload button, edit mode, API) and to make it non-editable since it is tied to a revision. But there are other pages, such as `XWiki.AllAttachments`, where I’m still not sure if it makes sense to display it or not (for the record, the summary for document revisions is not displayed on `XWiki.AllDocs`).

WDYT?  
Thanks.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [March 28, 2024, 12:47pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/2 "2024-03-28T12:47:04Z")

</div>

Some thoughts:

- I like the “summary” terminology since it’s the same one as we have when saving a page
- I doubt that users are going to use that summary field that frequently and I’d be in favor of not displaying it by default in the Attachment tables (either in the attachments extradoc table or in the Page Index). Also this would be consistent with the doc summary that we don’t display in the Page Index for example. This would mean that to see it, users would need to view the history for the attachments (e.g. [http://localhost:8080/xwiki/bin/viewattachrev/Main/WebHome/Screenshot%202023-10-20%20at%2016.15.39.png](http://localhost:8080/xwiki/bin/viewattachrev/Main/WebHome/Screenshot%202023-10-20%20at%2016.15.39.png)). I’d also add it by default in the attachment view LD ([http://localhost:8080/xwiki/bin/view/Main/?viewer=attachments](http://localhost:8080/xwiki/bin/view/Main/?viewer=attachments)). Now since this might not be enough, I’d add an Admin UI option to customize the attachment tables in the extradoc tab so that it can be added (but not used by default).
- To be decided (not sure) if we also want that admin UI option to control displaying a column for the summary in the attachments tab of the Page Index
- Last, I’d like @tkrieck or @amilica 's help to design the new input since the screenshot above would need to be improved a bit IMO
- Re edit, indeed, we could, FTM at least, consider it read only. I think it’s ok for a first version.

Thanks!

---

<div class="post-metadata">

**Author:** ![CharpentierLucas](https://forum.xwiki.org/user_avatar/forum.xwiki.org/charpentierlucas/32/4830_2.png) [@CharpentierLucas](https://forum.xwiki.org/u/CharpentierLucas)\
**Post date:** [March 28, 2024, 3:41pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/3 "2024-03-28T15:41:07Z")

</div>

Semantically I’m not sure `Comment` should match with anything like `summary` or `description`. E.g., I can put a `WIP` comment when uploading an attachment, but it would be a really bad description. I can put `Please do not change the size of this attachment` as a comment and it would be a bad version `summary`. If it’s not used by any extension, I’m okay with changing the semantics of this field (given we document it properly ofc).

If we decide that this comment field can be used as a `summary` or `description`, it would be great to provide it as a default image alternative text! Right now the default alt is the attachment filename, which is far from perfect. Note that it wouldn’t replace the alt defined in content, because ideally an alt text is context dependent, and the same attachment can be used in multiple contexts (which would make its description context independant).

For the pretty name, it depends a lot on what we prioritize as the main function of the field:

- `Summary` if we want its main function to be helping keep track of the version of the attachment
- `Description` if we want its main function to be helping figuring out what an attachment is
- `Text alternative` if we want its main function to be a default for filling up uses of this attachment in content.

From the way the ticket is described, it seems like `Summary` is the main function.

> [@pjeanjean](#):
>
> Finally, where exactly should this be displayed and how should it be edited? The issue mentions only that the field should be set during upload and displayed in the attachments list and the attachments history. If we consider this as a summary, I think it would make sense to have a default value for the different upload methods (upload button, edit mode, API) and to make it non-editable since it is tied to a revision. But there are other pages, such as `XWiki.AllAttachments`, where I’m still not sure if it makes sense to display it or not (for the record, the summary for document revisions is not displayed on `XWiki.AllDocs`).

I’m not sure about the exact way to edit it. But IMO if we consider it as a summary, we should still show it as editable (even if editing it actually creates a new revision of the attachment with an updated value, and doesn’t edit anything).

Thanks for this proposal!  
Lucas

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [March 28, 2024, 3:56pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/4 "2024-03-28T15:56:54Z")

</div>

> [@CharpentierLucas](#):
>
> But IMO if we consider it as a summary, we should still show it as editable (even if editing it actually creates a new revision of the attachment with an updated value, and doesn’t edit anything).

IMO it would be weird to edit a change summary and a first since we don’t do that for documents. Now if someone really wants to add a new change summary, they would always be able to download and re-upload the attachment with a new summary, so at least it’s not blocking. As I mentioned, I’d keep the editing feature for later as I don’t think we need it for the first version.

The only thing that worries me a bit more about the change summary concept for attachments is that when an attachment is added to the page, it’s not saved and the page needs to be saved for the attachment to be added. Thus there’s already the change summary of the page to take care of the summary…

If the attachment was saved independently of the page it would make sense to have its own change summary but since it’s not the case, I’m hesitating and wondering if change summary is the right way to view this.

Maybe this text is not actually a change summary but simply more an attachment title (or description), more similar to the document’s title. In this case, it’s something that should be editable and not related to the history. I have the feeling this makes more sense actually. WDYT?

---

<div class="post-metadata">

**Author:** ![pjeanjean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/pjeanjean/32/5901_2.png) [@pjeanjean](https://forum.xwiki.org/u/pjeanjean)\
**Post date:** [April 8, 2024, 8:55am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/5 "2024-04-08T08:55:19Z")

</div>

Going back to this proposal, here are a few more thoughts:

> [@CharpentierLucas](#):
>
> If we decide that this comment field can be used as a `summary` or `description`, it would be great to provide it as a default image alternative text!

I would agree for a description but I’m not sure it makes sense for a summary, I would expect the information provided to be wrt the upload itself and less to the image.

> [@vmassol](#):
>
> The only thing that worries me a bit more about the change summary concept for attachments is that when an attachment is added to the page, it’s not saved and the page needs to be saved for the attachment to be added. Thus there’s already the change summary of the page to take care of the summary…

The main idea here is to add the feature to the attachments tab, where the upload button is. This is in view mode, not edit mode, so there is no summary field to interact with and the save is done automatically. Now, from what I can see, a comment set on an attachment is automatically added to the default page summary:

 ![image](https://forum.xwiki.org/uploads/default/original/2X/f/f88ea81bd04ef1fca049ecb6bd20908cbbfcca0c.png)  
This was the existing behavior, I have not changed anything here.  
So, I think it still makes sense to view it as a summary.

> [@vmassol](#):
>
> In this case, it’s something that should be editable and not related to the history.

This would not fit the requirements of the original issue, that state that “On the history view of the attachment, all successive descriptions could be visible”.

---

<div class="post-metadata">

**Author:** ![surli](https://forum.xwiki.org/user_avatar/forum.xwiki.org/surli/32/2687_2.png) [@surli](https://forum.xwiki.org/u/surli)\
**Post date:** [April 9, 2024, 8:23am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/6 "2024-04-09T08:23:10Z")

</div>

Hi,

maybe I missed it in previous answers but I haven’t seen mention of the attachment summary in case of attachments added while editing a page? Are you planning to reuse directly the comment used for saving the page? That’s probably easiest way to start, knowing that ultimately we’d need a proper UI to select / edit the uploaded attachments during an edit session (see also [Loading...](https://jira.xwiki.org/browse/XWIKI-20041))

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [April 9, 2024, 8:45am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/7 "2024-04-09T08:45:54Z")

</div>

> [@pjeanjean](#):
>
> The main idea here is to add the feature to the attachments tab, where the upload button is. This is in view mode, not edit mode, so there is no summary field to interact with and the save is done automatically. Now, from what I can see, a comment set on an attachment is automatically added to the default page summary:
> 
> ![image](https://forum.xwiki.org/uploads/default/original/2X/f/f88ea81bd04ef1fca049ecb6bd20908cbbfcca0c.png)  
> This was the existing behavior, I have not changed anything here.  
> So, I think it still makes sense to view it as a summary.

That was exactly my point; you’ve shown it in your screenshot that there’s already a summary when an attachment is added. This is why I was wondering if it was making sense to add a second summary for attachments. Now Attachments do have a versioning store (`AttachmentVersioningStore`) so it’s possible to consider it a summary for that store, and displayed for the `viewattachrev` action (e.g. [http://localhost:8080/xwiki/bin/viewattachrev/Sandbox/WebHome/XWikiLogo.png](http://localhost:8080/xwiki/bin/viewattachrev/Sandbox/WebHome/XWikiLogo.png)).

However, if we do this, then it doesn’t make sense to have that summary displayed in the LD for attachments in the extradoc section at bottom of pages (since that LD is not related to attachment revision metadata). To view it differently, we don’t display the summary for a page in the Pages LD in Page Index.

It would make sense to display it in this extradoc attachment LD if it were a description or title for the attachment though. And in this case it would not make that much sense to display the attachment desc/title in the `viewattachrev` action viewer, since that desc/title would be attached to an attachment name (but it’s probably acceptable to display it if we want). This would also probably mean that we’d offer an LD action in the extradoc attachment table to edit/change the descriptiont/title for the attachment instead of an input box to be used when uploading the attachment.

> [@pjeanjean](#):
>
> This would not fit the requirements of the original issue, that state that “On the history view of the attachment, all successive descriptions could be visible”.

AFAIK the requirements you mentioned are not something that was discussed here and my understanding is that they can be changed.

---

<div class="post-metadata">

**Author:** ![pjeanjean](https://forum.xwiki.org/user_avatar/forum.xwiki.org/pjeanjean/32/5901_2.png) [@pjeanjean](https://forum.xwiki.org/u/pjeanjean)\
**Post date:** [April 9, 2024, 9:54am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/8 "2024-04-09T09:54:52Z")

</div>

Ok, I see your point now.

> [@vmassol](#):
>
> AFAIK the requirements you mentioned are not something that was discussed here and my understanding is that they can be changed.

We should probably ask for @Jsd 's input on this part, however, as the original reporter.

---

<div class="post-metadata">

**Author:** ![tkrieck](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tkrieck/32/6019_2.png) [@tkrieck](https://forum.xwiki.org/u/tkrieck)\
**Post date:** [April 11, 2024, 11:10am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/9 "2024-04-11T11:10:44Z")

</div>

Hey everyone.

For the layout on the upload fields, you could just move the description field above the file selector. At least to give the user a chance of writing something before uploading (as it is automatic).

Otherwise, it would be best to give this whole section an “upload” button. So the user can select the files, write a summary, then click upload. For this specific discussion, maybe this is too much of a change, but I will try to get a proposal on this specific topic later on.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [April 11, 2024, 11:38am UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/10 "2024-04-11T11:38:25Z")

</div>

Thanks @tkrieck for looking into this!

Small note that we’re thinking to make this attachment upload summary optional and turned off by default (it would be shown if enabled in the xwiki config).

---

<div class="post-metadata">

**Author:** ![Jsd](https://forum.xwiki.org/user_avatar/forum.xwiki.org/jsd/32/4424_2.png) [@Jsd](https://forum.xwiki.org/u/Jsd)\
**Post date:** [April 11, 2024, 5:02pm UTC](https://forum.xwiki.org/t/create-a-description-field-for-page-attachments/14346/11 "2024-04-11T17:02:58Z")

</div>

Hello, the mockup in the ticket came from my own guesses, but I confirm that this new field should be visible in the history of attachments. It will allow to update it with new versions of each file if I understood well, which is aligned with the proposal.  
To have it displayed in the livetable of the attachments is therefore less relevant.  
Thanks!
