DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Show Images In Web Directory List

06.03.2005
| 13051 views |
  • submit to reddit
        I was tired of found lots of images in a directory, and click in each one to see if someone of these are really cool are soooo dirty.

I wrote this bookmarklet, that create a new document with all the images opened in a table.
NSF56k but nice.

javascript:function showallimagesindirectory(){var s='test';var dc='<b>Images in: '+location.href+'</b><table border=1 style=\'font:x-small verdana\'>';for(var i=0;i<document.links.length;i++){s=document.links[i].href;if(s.toUpperCase().lastIndexOf('.JPG')!=-1 || s.toUpperCase().lastIndexOf('.JPEG')!=-1 || s.toUpperCase().lastIndexOf('.GIF')!=-1 || s.toUpperCase().lastIndexOf('.PNG')!=-1){dc+='<tr>';dc+='<td><img src='+s+'> </td>';dc+='</tr>';}}dc+='</table>';var iw=window.open('','iw','');iw.document.open();iw.document.write(dc);iw.document.close();}showallimagesindirectory();

enjoy!    

Comments

Snippets Manager replied on Wed, 2007/06/27 - 10:10am

Very nice. I extended it because I had problems when the directory contained hundreds of images. You have to click on the bookmarklet again to advance. You can set the number of images on the page and the start point. javascript:function showallimagesindirectory(){var s='';var limit=20;var total=document.links.length;var start=0;if (document.getElementById('xmystart')) start=document.getElementById('xmystart').value;if (document.getElementById('xmylimit')) limit=document.getElementById('xmylimit').value;var dc='Images in: '+location.href+'Images in: '+location.href+'
Total: '+total+'; Start Limit
';for(var i=start,p=0;i';p++;}if(p==limit){break;}}dc+='
'+t+'
';for(var i=0;i'+t+''+'
';}}dc+='';var iw=window.open('','iw','');iw.document.open();iw.document.write(dc);iw.document.close();}showallimagesindirectory();