Note that there are some explanatory texts on larger screens.

plurals
  1. POmodifying an enlargement image from thumbnail script to dynamically display image based on their size property
    primarykey
    data
    text
    <p>I'm trying to modify this simple js script that enlarges the image from thumbnail whenever it is clicked. The problem is , the enlarged image is displayed according to an define fixed width. I want the enlarged image displayed according to it's size property.For example of an image size is 200 width and 300 height , I want that image to be display according to that size instead of an fixed 300 height and width.</p> <p>I'm been trying solutions such as removing the width but instead the image is enlarged to the full screen size.</p> <p>How can I modify this script so the enlarged image is displayed according to it's original size property.</p> <p>The script belongs to roXon and I give full credit to him <a href="https://stackoverflow.com/questions/13575061/how-to-enlarge-image-from-thumbnail-in-jquery">How to enlarge image from thumbnail in jQuery?</a></p> <p>This is the jquery <a href="http://jsbin.com/egevij/3/edit" rel="nofollow noreferrer">http://jsbin.com/egevij/3/edit</a></p> <p>HTML</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="css/forms.css"&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;Demo by roXon&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="jQ_popup_window"&gt; &lt;div id="jQ_popup" class="shadow radius"&gt; &lt;div id="jQ_popup_close"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;img src="http://placehold.it/250x150/cf5" data-full="1.jpg" alt="" /&gt; &lt;img src="http://placehold.it/250x150/fof" data-full="http://placehold.it/860x590/fof" alt="" /&gt; &lt;script type = "text/javascript" src ="trouble.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>jQuery:</p> <pre><code> // POPUP WINDOW: var scrT = $(window).scrollTop(); $(window).scroll(function(){ scrT = $(window).scrollTop(); }); // GET and use WINDOW HEIGHT // $.getDocHeight = function(){ var D = document; return Math.max(Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight)); }; // POPUP WINDOW (lightbox for video and other) // GET WINDOW SCROLLtop OFFSET $('[data-full]').on('click', function(e){ e.preventDefault(); $('#jQ_popup').css({ top: scrT+15 }).find('img').remove(); $('#jQ_popup_window').height($.getDocHeight).fadeTo(0,0).css({ marginLeft:0 }).fadeTo(600,1); var imgToLoad = $(this).data('full'); $('&lt;img&gt;', {src:imgToLoad, width:'100%'}).appendTo('#jQ_popup'); }); // close popup $('#jQ_popup_close, #jQ_popup_window').on('click', function(){ $('#jQ_popup_window').fadeTo(600,0,function(){ $(this).hide(); }); }); $('#jQ_popup').on('click', function(ev){ ev.stopPropagation(); }); // end POPUP WINDOW </code></pre> <p><strong>CSS:</strong></p> <pre><code>/* === POPUP WINDOW === */ #jQ_popup_window{ background: rgba(0,0,0,0.6); left: 0; margin-left: -9000px; position: absolute; top: 0; width: 100%; z-index:999999; } #jQ_popup { background: #000; border: 1px solid #BDB9B8; margin: 30px auto; padding: 25px; position: relative; width: 600px; /* SET HERE DESIRED W .*/ } #jQ_popup_close { background:#fff; cursor: pointer; height: 28px; width: 28px; position: absolute; z-index:999999; right: 10px; top: 10px; -webkit-border-radius:30px; border-radius:30px; border:2px solid #fff; border-color: rgba(255,255,255,0.2); } #jQ_popup_close:hover{ background:#f00; } /* #POPUP WINDOW */ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload