Skip to content

Commit 10a6a69

Browse files
author
kasperg
committed
Refactored code to use jQuery features.
Repositioned file size text.
1 parent f04c6bf commit 10a6a69

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

lighthouse-inline-images.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
77
// ==/UserScript==
88

9-
var width = $("div#main div.attachments").width();
10-
11-
$("ul.attachment-list li.aimg a").each(function()
12-
{
13-
img = document.createElement('img');
14-
img.setAttribute('src', this.getAttribute('href'));
15-
img.setAttribute('style','max-width: ' + (width-45) + 'px;');
16-
this.replaceChild(img, this.firstChild);
17-
});
9+
$(document).ready(function() {
10+
var width = $("#main .attachments").width();
11+
12+
$(".attachment-list li.aimg a").each(function()
13+
{
14+
//replace link to image with actual image
15+
jQuery(this).html(
16+
jQuery('<img/>')
17+
.attr('src', $(this).attr('href'))
18+
.css('max-width', (width-45)+'px'));
19+
//readjust positioning of file size
20+
jQuery(this).siblings('.file-size').css({
21+
'top': 'auto',
22+
'bottom': '9px'
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)