Soon after recreating my blog using Jekyll and Github pages, i realized that my images on the main page were too large for the view. Instead of fixing the images (as i assume i may include even larger images in the future), i decided to put in a simple hack that the Confluence Wiki inspired.
Example
I figured i’d limit the image size, then popup a full size view in a jQuery dialog.
Limit the image size
Add jQuery and jQuery UI
Add JavaScript on click handler
Put this right before the end of your body tag. This code adds a delegate to the body that handles the click event for ‘img’ tags. It then creates an ‘img’ element, sets the src and appends it to a new ‘div’ element. This it calls .dialog() on and sets the dialog title to the ‘alt’ attribute of the image.
Change the cursor for the images
This can be done via CSS or jQuery, your choice.
I have no images in my theme, so this works well. This may cause issues for you however, so you could add a class (like ‘popup’) to the images. You’d simply have to change the ‘delegate’ method call to :
Comments