Information:
I'm trying to make a simple photo gallery. I want to show the image clicked in large size in the center of the screen. (Clicar em 0.jpg e mostrar em uma outra div 0Large.jpg)
Problem:
With the code I have I can do this, but only really showing the clicked image. The problem is that this image clicked will be of a different size (it will be something like thumbnail) so clicking the image that appears is small. I want to show a large version. Ex: 001Large.jpg
instead of 001.jpg
. I do not know how to do that. I thought of using a kind of loop in the variable that contains the image address until it finds the ".jpg" and insert before the text ".jpg" the name "Large" so that the big version of the image is shown.
I have an HTML similar to this:
<div id="gallery-work">
<div id="gallery-warper" >
<div class="img-container" >
<img src="img/gallery/work/001.jpg" alt="" width="100%" />
</div>
<div class="img-container" >
<img src="img/gallery/work/002.jpg" alt="" width="100%" />
</div>
<div class="img-container" >
<img src="img/gallery/003.jpg" alt="" width="100%" />
</div>
<div class="img-container" >
<img src="img/gallery/004.jpg" alt="" width="100%" />
</div>
</div>
And JavaScript:
$(document).ready(function () {
$("img").click(function() {
var imgLocation = $(this).attr("src");
var newImgLocation = '<div id="showimg" class="midway-horizontal midway-vertical"><img class="imgshow midway-horizontal midway-vertical" src="' + imgLocation + '"/></div>';
$(".main-container").append(newImgLocation);
Midway();
$("#showimg").click(function() {
$(this).remove();
});
});
});
JSFiddle Example
Note: