ubc / wiki-embed

WordPress plugin that lets you embed mediawiki pages into your site, sites like Wikipedia
19 stars 10 forks source link

Images: domain missing in scr #4

Open riweckr opened 11 years ago

riweckr commented 11 years ago

Hi,

the url in scr is incomplete: src="/wiki/images/thumb/..." should be src="http://my.wiki.org/wiki/images/thumb/..."

MrStevns commented 9 years ago

i've come up with a semi-solution. Add this piece to wiki-embed-overlay.js $('.thumbimage').attr('src', 'URL' + $('.thumbimage').attr('src'));

change URL to your wiki, the rest of the link will append. For example: $('.thumbimage').attr('src', 'http://my.wiki.org/' + $('.thumbimage').attr('src'));

I'm calling it a semi-solution because it requires you to make changes to the plugin itself. Ideally it should have a input box on the settings page, where you would be able to insert the url, but i haven't figured out how to get the input url and use it in js.

I've made further improvement to this. I discovered later that images shown in a gallery also uses relative urls, but they don't have any id or class defined. Therefore i've come up with this "solution":

 //if any image is found, add imagegally class, else show alert
 var addToImage =  $('img');
 addToImage.addClass(function() {
         if (addToImage.width()) {
                 addToImage.addClass( "imagegallery" );
         }

         else {
             alert('something went wrong');
         }
 });

     //Adds a ID tag with a number based on the number of images found in .imagegallery.
 $(".imagegallery").each(function(i) {
    $(this).attr('id', "image" + (i + 1));
     });

 //change the url to your destination
 var url = "http://wiki.mywiki.org";

$("li").each(function(i) {
    $('#image' + (i+1)).attr('src', url + $('#image' + (i+1)).attr('src'));
});