Difference between revisions of "Widget:ImageLoader"
m (whoops, wrong function reference) |
m (Image on-error link success! Restoring original demo image) |
||
(One intermediate revision by the same user not shown) | |||
Line 16: | Line 16: | ||
This will give the following result:<br/> | This will give the following result:<br/> | ||
{{#widget:{{PAGENAME}} | {{#widget:{{PAGENAME}} | ||
− | |url= | + | |url=https://upload.wikimedia.org/wikipedia/commons/b/b8/Trojan_Room_coffee_pot_xcoffee.png |
|width=156 | |width=156 | ||
|height=175 | |height=175 | ||
Line 51: | Line 51: | ||
function imgFail() | function imgFail() | ||
{ | { | ||
− | |||
// Try and make 'old' image sepia on error | // Try and make 'old' image sepia on error | ||
setFilter( this.img, "grayscale(100%) sepia(100%)" ); | setFilter( this.img, "grayscale(100%) sepia(100%)" ); | ||
this.loading = false; | this.loading = false; | ||
+ | if ( !this.link ) | ||
+ | { | ||
+ | this.link = this.img.parentNode.insertBefore( document.createElement( "a" ), this.img ); | ||
+ | this.link.target = "_blank"; | ||
+ | this.link.href = this.src; | ||
+ | this.link.textContent = "Open image"; | ||
+ | } | ||
} | } | ||
Latest revision as of 13:10, 17 October 2016
This widget allows you to embed images from non-https sources on your wiki page.
Created by Xopr
Using this widget
To insert this widget, use the following code:
{{#widget:ImageLoader |url=https://upload.wikimedia.org/wikipedia/commons/b/b8/Trojan_Room_coffee_pot_xcoffee.png |width=300 |height=250 |interval=60 }}
This will give the following result:
Note that url is mandatory, the rest is optional (leave out interval to make the image static)
Copy to your site
To use this widget on your site, just install MediaWiki Widgets extension and copy full source code of this page to your wiki as Widget:ImageLoader article.