How to retrieve older version of JPG attachments
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
The older version of JPEG attachments isn't accessible from the Confluence UI. Even clicking on the older version from attachment page will only display the latest version of JPEG file
- Navigate to Confluence Page > Attachments.
- Attach the first version of the JPG image in the attachment.
- Attach the second version of the JPG image in the attachment with the same attachment name.
- Click to preview the first version of the JPG image.
Environment
All versions of Confluence regardless of the environment
Cause
Confluence preview URL is having the parameter version=1 while accessing the second version (latest) of the JPG image
{code}<BASE_URL>/download/attachments/1966087/example.jpg?version=1&modificationDate=1509703152000&api=v2{code}
Workaround
This is a known bug - CONFSERVER-54125Getting issue details... STATUS and the only workaround is to change the format to .png.To access the older version, we would need to manually change the format from .JPG to .PNG in the database
Note the CONTENTID of the JPG image
select contentid from content where title = '<JPG attachment title>' and contenttype='ATTACHMENT'
Update the CONTENT table by replacing .jpg in the title by .png
update content set title='<title of attachment>.png',lowertitle='<title of attachment>.png' where contentid in (select contentid from content where title = '<JPG attachment title>' and contenttype='ATTACHMENT')
Update the CONTENTPROPERTIES table to change the MEDIATYPE property
update contentproperties set stringval='image/png' where propertyname='MEDIA_TYPE' and contentid in (select contentid from content where title = '<JPG attachment title>' and contenttype='ATTACHMENT')
Flush the Cache or Restart Confluence to see the changes in UI
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.