Skip to content

Instantly share code, notes, and snippets.

@jdsimcoe
Created October 25, 2012 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdsimcoe/3954657 to your computer and use it in GitHub Desktop.
Save jdsimcoe/3954657 to your computer and use it in GitHub Desktop.
Image Index Preview
(function($) {
/**
* This plugin adds image preview to the publish pages.
*
* @author: Nils Hörrmann, post@nilshoerrmann.de
* @source: http://github.com/nilshoerrmann/image_index_preview
*/
$(document).ready(function() {
$('table td[class*="upload"], fieldset div[class*="upload"]').addClass('upload').find('a').each(function() {
var link = $(this),
href = link.attr('href'),
size = (Symphony.Context.get('env')['page'] == 'index' ? '40/40' : '0/150')
file = href.replace(Symphony.Context.get('root') + '/workspace/', '');
// Append preview
if(file) {
if(file.match(/\.(?:bmp|gif|jpe?g|png)$/i)) {
// Remove file name
link.text('');
// Add image
$('<img />', {
src: Symphony.Context.get('root') + '/image/2/' + size + '/5/' + file
}).prependTo(link);
}
}
});
});
})(jQuery.noConflict());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment