Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to dynamically display image properties with jQuery/Ajax?
    primarykey
    data
    text
    <p>I'm using simple gallery script which dynamically loads image when user clicks on thumbnail :</p> <pre><code>$(document).ready(function() { $('.thumbnailB').live("click", function() { $('#mainImage').hide(); var i = $('&lt;img /&gt;').attr('src',this.href).load(function() { $('#mainImage').attr('src', i.attr('src')); $('#imageWrap').css('background-image', 'none'); $('#mainImage').fadeIn(); }); return false; </code></pre> <p>here is script demo : <a href="http://www.micahcarrick.com/code/jquery-image-swap/index.html" rel="nofollow">http://www.micahcarrick.com/code/jquery-image-swap/index.html</a></p> <p>and PHP which uses filename and then explode to display image properties under image :</p> <pre><code>// this variable has to contain current image when user clicks on thumbnail $filename = " "; $fileinfo = explode("-", $filename); echo $filename; ?&gt; &lt;BR&gt;&lt;strong&gt;Filesize :&lt;/strong&gt; &lt;?php echo $fileinfo[1]; ?&gt; &lt;?php $resolution=$fileinfo[2]; $res = explode("x", $resolution); ?&gt; &lt;BR&gt;&lt;strong&gt; Width : &lt;/strong&gt;&lt;?php echo $res[0]; ?&gt; &lt;BR&gt;&lt;strong&gt; Height : &lt;/strong&gt;&lt;?php echo $res[1]; ?&gt; &lt;/div&gt; </code></pre> <p>HTML :</p> <pre><code>&lt;a href="/download/thumbnail/big/Photo01-310KB-500x381-thbig.png" class="thumbnailB"&gt; &lt;img src="/download/thumbnail/small/Photo01-310KB-500x381-thsmall.png" alt="Image 1"/&gt; &lt;/a&gt; &lt;a href="/download/thumbnail/big/Photo02-328KB-500x353-thbig.png" class="thumbnailB"&gt; &lt;img src="/download/thumbnail/small/Photo02-328KB-500x353-thsmall.png" alt="Thumbnail 2"/&gt; &lt;/a&gt; &lt;div id="imageWrap"&gt; &lt;img src="/download/thumbnail/big/Photo01-310KB-500x381-thbig.png" alt="Main Image" id="mainImage"/&gt; &lt;/div&gt; </code></pre> <p>How to grab image name and pass it into $filename variable from Jquery to PHP ? 1) grab and send #mainImage image name when page is loaded and then 2) grab and send .thumbnailB image name each time user clicks on thumbnail </p> <p>I have a lot of images - using Jquery/PHP explode to display image properties would save me from database input, photos will be stored on Amazon S3 that's why information(image resolution) has to be encoded into filename or database.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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