File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 6
6
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
7
7
// ==/UserScript==
8
8
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments