How to retrieve older version of JPG attachments
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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-54125 - Older JPG attachment version preview the latest version in Confluence 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
1
select contentid from content where title = '<JPG attachment title>' and contenttype='ATTACHMENT'
Update the CONTENT table by replacing .jpg in the title by .png
1 2
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
1
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 making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Was this helpful?