Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9089831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:14:07+00:00 2026-06-16T22:14:07+00:00

I have a small problem. i have a link and when i click on

  • 0

I have a small problem. i have a link and when i click on this link i want an image to grow to a certain size and move to a certain spot on the screen. Everthing goes fine except that the image pops back to it’s original size after the animation is complete.

My project is in Magento so sorry about the weird display of the image

PS: In the img tag it says width=”235″ height=”401″.
But the image pops to width=924″ and height=”1379″. These are the dimensions of the actual image.

Here is my HTML code:

<a class="lightbox"href="#">pic</a>
<p class="product-image">
<?php
    $_img = '<img id="image1" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" width="235" height="401  "  />';
    echo $_helper->productAttribute($_product, $_img, 'image');
?>

And here is my jQuery code:

(function(window, $, undefined) {

jQuery(function(){
    $('.lightbox').click(function(e) {
        $('body').css('overflow-y', 'hidden'); // hide scrollbars!
        var clicked = $('.lightbox').position();

        $('<div id="overlay"></div>')
          .css('top', $(document).scrollTop())
          .css('opacity', '0')
          .animate({'opacity': '0.5'}, 'slow')
          .appendTo('body');

        $('<div id="lightbox"></div>')
          .hide()
          .appendTo('body');

        var img = new Image();
        img.onload = function() {

            var width  = img.width,
                height = img.height;

            $('<img />')
              .attr('src', img.src)
              .load(function() {
                positionLightboxImage(e, width, height);
              })
              .click(function() {
                removeLightbox();
              })
              .appendTo('#lightbox');
        };
        img.src = $('#image1').attr('src');

        /*var height = $('<img />').attr('width', .width());
        alert(height);

        $('<img />')
          .attr('src', $(this).attr('href'))
          .load(function() {
            positionLightboxImage(e);
          })
          .click(function() {
            removeLightbox();
          })
          .appendTo('#lightbox');

        return false;*/
        e.preventDefault();
      });
});


    function positionLightboxImage(e, width, height) {
      var top = e.pageY - (height / 2);
      var left = e.pageX - (width / 2);
      $('#lightbox')
        .css({
          'top': top,
          'left': left
        })
        .fadeIn(1)
        .animate({'width': '50px'}, 3000);
    }

    function removeLightbox() {
      $('#overlay, #lightbox')
        .fadeOut('slow', function() {
          $(this).remove();
          $('body').css('overflow-y', 'auto'); // show scrollbars!
        });
    }

    jQuery.fn.center = function () {
        this.css("position","absolute");
        this.css("top", Math.max(0, (($(window).height() - this.outerHeight()) / 2) + 
                                                    $(window).scrollTop()) + "px");
        this.css("left", Math.max(0, (($(window).width() - this.outerWidth()) / 2) + 
                                                    $(window).scrollLeft()) + "px");
        return this;
    }

})(window, jQuery);

I hope i gave enough information. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:14:08+00:00Added an answer on June 16, 2026 at 10:14 pm

    For anyone who is interested in this answer.

    It isn’t the best way to fix this.
    But using a smaller image for the lightbox and keeping the big image in the data-src did the trick for this situation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem where I want to find the next active item
I have this small problem with jquery: I need to do something like this:
I have small problem when trying to create many-to-many link in doctrine. I have
I have a small problem. So I have this page that loads dynamic content
i have a small problem with a jquery click trigger. in my index.php i
have small problem, and would very much appreciate help :) I should convert byte
I have small problem with Spring MVC. Basically what I'm trying to do is
I have a small problem and I've figured out where when and why it
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.