Enforcing maximum image width in a table
We have a Confluence page that contains a Jira macro; the macro outputs a tables that includes fields from the Jira issue. Some of the Jira description fields include images.
When this page is exported to PDF, the macro is exported as a table, but we have an issue sizing the images.
By default, they are set such that they fill 100% of the cell; this is bad for the smaller images which get enlarged and lose resolution.
I can ensure that they are set to their natural size by specifying:
table img {
width: auto !important;
}
This ensures they are not re-scaled, but it means that the larger images overrun.
To prevent this, I have added a max-width to the CSS, but it turns out this does not affect table cell contents (it's just ignored).
For the record, I also fix the column widths and set table-layout to fixed as shown below.
td:nth-child(1).jira-macro-table-underline-pdfexport * {
width: 3cm !important;
}
td:nth-child(2).jira-macro-table-underline-pdfexport * {
width: 3cm !important;
}
td:nth-child(3).jira-macro-table-underline-pdfexport * {
width: 13cm ;
}
td:nth-child(4).jira-macro-table-underline-pdfexport * {
width: 4cm !important;
}
table {
table-layout:fixed !important;
}
table img {
width: auto !important;
max-width: 10cm !important;
}
It seems that it's actually part of the CSS spec that max-width doesn't apply to table contents, but some sites suggest setting the display parameter (e.g. to block) for the image elements in the table.
Any ideas?
Thanks,
Guy.
-
Hi Guy,
unfortunately the max-width CSS property is currently not supported.
However, the requirement is already tracked in our JIRA System: https://k15t.jira.com/browse/EXP-395
Please sign up at https://k15t.jira.com/secure/Signup!default.jspa to watch, comment on or vote for this issue. You'll then get a notification for every status update on the issue.Best,
Nils
Please sign in to leave a comment.
Comments
1 comment