Skip to content

Commit 95691c1

Browse files
committed
thumbnails+
1 parent bac8b02 commit 95691c1

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

attachment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
do_logincheck();
66

77
$id = $_GET['id'];
8-
$thumbnail = isset($_GET['thumbnail']);
8+
$thumbnail = (bool) ($_GET['thumbnail'] ?? 0);
99

1010
$attachment = jira_get('attachment/' . $id);
1111

inc.functions.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,13 @@ function do_remarkup( $html ) {
126126
$html = str_replace('="/', '="' . JIRA_ORIGIN . '/', $html);
127127

128128
// Images through proxy
129-
$regex = '#src="' . preg_quote(JIRA_URL, '#') . '/secure/(?:attachment|thumbnail)/(\d+)/([^"]+)"#';
130-
$html = preg_replace($regex, 'data-attachment="$1" data-context="markup" data-src="attachment.php?thumbnail=1&id=$1"', $html);
129+
$html = preg_replace('# (width|height)="\d+"#', '', $html);
130+
$regex = '#src="' . preg_quote(JIRA_URL, '#') . '/secure/(attachment|thumbnail)/(\d+)/([^"]+)"#';
131+
$html = preg_replace_callback($regex, function($match) {
132+
[, $size, $id, $name] = $match;
133+
$thumb = (int) ($size == 'thumbnail');
134+
return 'data-attachment="' . $id . '" data-context="markup" data-src="attachment.php?thumbnail=' . $thumb . '&id=' . $id . '"';
135+
}, $html);
131136
$regex = '#href="' . preg_quote(JIRA_URL, '#') . '/secure/attachment/(\d+)/([^"]+)"#';
132137
$html = preg_replace($regex, 'target="_blank" href="attachment.php?id=$1"', $html);
133138

style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ button[data-preview] {
194194
display: inline-block;
195195
padding: 0 2px;
196196
}
197+
.markup img {
198+
max-width: 100%;
199+
}
197200

198201
.jira-issue-macro {
199202
display: inline-block;

0 commit comments

Comments
 (0)