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 7688873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:01:38+00:00 2026-05-31T20:01:38+00:00

I’d like to show an image as big as possible. When the user is

  • 0

I’d like to show an image as big as possible. When the user is clicking it in the galerie, it’ll be loaded via ajax and should be resized. Again, the resizing isn’t the problem, if I’m using it by a click-event, it works perfectly, but it’s not correctly triggered, if I include it like this:

$('.thumbnail').click(function() { 
  id = $(this).attr('id');
  $('#picbox').fadeIn(fadeSpeed);
  $('#picture').load("/propfe/ajax/picture/" + id);
  $('#picture').fadeIn(fadeSpeed);

  $('#bigpic').ready(function() {
    var browserHeight = $(window).height() - 200;
    var browserWidth = $(window).width() - 200;
    var height = $('#bigpic').height();
    var width = $('#bigpic').width();

    var picRatio = width / height;
    var windowRatio = browserWidth / browserHeight;

    if(picRatio < windowRatio) {
        $('#bigpic').css({ "height": browserHeight + "px" });
    }
    if(picRatio > windowRatio) {
        $('#bigpic').css({ "width": browserWidth + "px" });
    }

  });

  $('.pic_loader').fadeOut(fadeSpeed, function() {
     $('.pic_loaded').fadeIn(fadeSpeed);
  });
});

So far, I think I’ll explayn it shortly, maybe you don’t really have to read this paragraph: The code is triggered by clicking on the thumbnail. First, it gets the id of the picture, that should be loaded and fades in the div, everything will be loaded in and with a loading-gif. After that, the ajax-request will be send, the result will be faded in and when it’s ready, the image (id=bigpic) should be resized. The last lines aren’t very interesting, they just fade out the loading-gif and fading in all the rest, the code is generating.

When I tried to give out some variables, the alert is given before anything is faded in and the width and the height of the picture is null, so I think, the code is triggered before the picture is loaded.

So how is it possible, it is just executed, if the image is fully loaded?

  • 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-05-31T20:01:40+00:00Added an answer on May 31, 2026 at 8:01 pm

    I’ve found another solution:
    Via jQuery I get the values of my browsers height and width. I send them with ajax to my script and simply calculate my width and height in the request. Additionaly, I use my old jQuery function with $(window).resize to resize the image, if the dimensions of the browser are changed.
    Works perfectly 🙂

    ajax-request:

    $('.thumbnail').hover(function() {
      $('.thumbnail').css({ "cursor": "pointer" });
    });
        var browserHeight = $(window).height();
        var browserWidth = $(window).width();
    
    $('.thumbnail').click(function() { 
        id = $(this).attr('id');
      $('#picbox').fadeIn(fadeSpeed);
      $('#picture').load("/propfe/ajax/picture/" + id + '/' + browserWidth + '/' + browserHeight, function() {  
      });
      $('#picture').fadeIn(fadeSpeed);
    
          $('.pic_loader').fadeOut(fadeSpeed, function() {
             $('.pic_loaded').fadeIn(fadeSpeed);
          });
    });
    

    resizing with jQuery:

    $(window).resize(function() {
      var browserHeight = $(window).height();
      var browserWidth = $(window).width();
      var windowRatio = browserWidth / browserHeight;
    
      var height = $('#bigpic').height();
      var width = $('#bigpic').width();
      var picRatio = width / height;
    
      if(picRatio < windowRatio) {
            $('#bigpic').css({ "height": browserHeight - 180 + "px" });
        }
        if(picRatio > windowRatio) {
            $('#bigpic').css({ "width": browserWidth -150 + "px" });
        }
    });
    

    resizing in the requested php-script (the shadow-helper is a helper I’ve build on my own)

    <?php 
    $ratio = $height / $width;
    $iA = getimagesize("img/".$picture['Picture']['url']); 
    $bild["width"] = $iA[0]; 
    $bild["height"] = $iA[1];
    $pRatio = $bild["height"] / $bild["width"];
    $nwidth = null; $nheight = null;
    if($pRatio < $ratio) { $nwidth = $width - 150; }
    elseif($pRatio > $ratio) { $nheight = $height - 180; }
    echo $this->Shadow->image($picture['Picture']['url'], 'big', $nwidth, $nheight); 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.