Different size of images on page than defined using rest API

shroomba December 16, 2024

Hi,

we are using Confluence rest API to upload images to our Confluence pages. The HTML we send through PUT request is this:

'<ac:image ac:width="800"><ri:attachment ri:filename="{image_file_name}"/></ac:image>'
however the size of the image on the page is 1011.
I then tested different sizes with the same image but with different names, not one of them matched the defined size and also I couldn't find any pattern:
- uploaded 100, size on page 78
- uploaded 200, size on page 196
- uploaded 300, size on page 314
- uploaded 400, size on page 423
- uploaded 500, size on page 549
uploaded 600, size on page 666
uploaded 700, size on page 1011
uploaded 800, size on page 1011
uploaded 900, size on page 1011
uploaded 1000, size on page 1409
Why do sizes not match what we define?
Thank you for your answer,
Sara

2 answers

1 accepted

1 vote
Answer accepted
shroomba January 21, 2025

We found a solution: in the image tag definition, we added this ac:custom-width="true" and it helped, so now the image tag looks like this: <ac:image ac:width="{pixel_width}" ac:custom-width="true">

0 votes
Tomislav Tobijas _Koios_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2024

Hi @shroomba ,

I've never used this but can you try adding widthType parameter when using PUT request and setting it to pixel? I've just checked JSON format of one page where the image is attached and I can see that, alongside of width value, there's this widthType value stated as well.

2024-12-16 09-56-22.png

Cheers,
Tom

shroomba December 16, 2024

I checked on our page and this width relates to the size of the attachment, not the displaying size of the image, because in our case, the original size of attachment is 2700x1800, but I want it displayed at 600. So, in atlas_doc_format request, I get this:

"content":[{"type":"media","attrs":{"width":2700,"type":"file","height":1800}}]}]

 but the image is still sized at 666 on the page.

Tomislav Tobijas _Koios_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 17, 2024

Hmm, I can see two width attributes here - one for the displayed image/layout, and one for the actual size.

image1.png

I've used Jira but not Confluence APIs so I can't say I'm an expert on this. 

You might want to check this out with Atlassian Support as they probably have staff who have more knowledge on this.

If you do get this to work, I would appreciate it if you would share the resolution here.

Cheers,
Tom

shroomba December 20, 2024

We found a solution: in the image tag definition, we added this ac:custom-width="true" and it helped, so now the image tag looks like this: <ac:image ac:width="{pixel_width}" ac:custom-width="true">

Tomislav Tobijas _Koios_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2024

Cool thing to know 👀

@shroomba thanks for sharing!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events