Last active
August 29, 2015 14:20
-
-
Save thotbox/e5b8eb3604c7ddc71ca9 to your computer and use it in GitHub Desktop.
JavaScript: Grid Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Grid Images | |
$(document).ready(function() { | |
if($('.grid_images').length && $('.grid_image').length) { | |
$('.grid_image').each(function() { | |
var gridID = $(this).attr('id'); | |
gridID = gridID.replace('grid_image_', ''); | |
var gridImage = $('#grid_source_' + gridID).attr('data-src'); | |
var gridFloat = $('#grid_source_' + gridID).attr('data-float'); | |
var gridWidth = $('#grid_source_' + gridID).attr('data-width'); | |
$(this).html('<img src="' + gridImage + '">'); | |
if (gridFloat === 'left') { | |
$(this).addClass('grid_image_left'); | |
} else if (gridFloat === 'right') { | |
$(this).addClass('grid_image_right'); | |
} | |
if (gridWidth === 'half') { | |
$(this).addClass('grid_image_half'); | |
} else { | |
$(this).addClass('grid_image_full'); | |
} | |
$('#grid_source_' + gridID).remove(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment