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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:50:21+00:00 2026-05-12T20:50:21+00:00

I need to display an image in a fixed size div. Under the div

  • 0

I need to display an image in a fixed size div.
Under the div must be some control, like a cursor bar, which sets the resolution of the displayed image.
I don’t mind much writing the thing, but I thought it might already exist. How come I can’t find such a thing ?

(I am not interested in things like jQZoom nor zoomimage which do not let the user choose dynamically the display resolution.)

  • 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-12T20:50:22+00:00Added an answer on May 12, 2026 at 8:50 pm

    As this question has now been seen more than 1k times, I add my solution to it. Feel free to copy and adapt.

    The solution involves jQuery UI slider plugin. Mainly we create a div with fixed size, overflow:scroll, containing a img tag, and we add a slider under it. The slider ‘change’ event is bound to a rescale of the img@width/@height attributes.

    Here is an excerpt of what we did :

    HTML

        <div id="pictureFilePreview">
            <img id="pictureFilePreviewImg" src="style/images/spacer.gif"/>
        </div>
        <div id="pictureSlider"/>
    

    JS

    $('#pictureFilePreview').css('overflow','scroll');
    $('#pictureFilePreviewImg')
        .attr("src", "http://url.of.the.image")
        .css("display","block")
        .bind("load", function(){ //wait for complete load of the image
            // Slider  
            var initHeight = parseInt($('#pictureFilePreviewImg').attr("height"));  
            var initWidth = parseInt($('#pictureFilePreviewImg').attr("width"));  
            if ($('#pictureFilePreview').width() < initWidth 
                || $('#pictureFilePreview').height() < initHeight) {                
    
                var deltaW = $('#pictureFilePreview').width() - initWidth;  
                var deltaH = $('#pictureFilePreview').height() - initHeight;
                var ratio = 0;
                if (deltaW < deltaH) {
                    ratio = ($('#pictureFilePreview').width() / initWidth) * 100;
                } else {
                    ratio = ($('#pictureFilePreview').height() / initHeight) * 100;
                }
                $('#pictureSlider').slider({  
                    range: false,
                    min : ratio,
                    values: [100],
                    change: function(event, ui) {  
                        var newHeight = ((initHeight) * ui.value / 100);  
                        var newWidth = ((initWidth) * ui.value / 100); 
                        $('#pictureFilePreviewImg').attr("height",newHeight);  
                        $('#pictureFilePreviewImg').attr("width",newWidth);  
                        $('#pictureFilePreview').css('overflow',ui.value === 0?'visible':'scroll');  
                    }  
                }); 
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display an arbitrarily-sized image inside a fixed-size block. The image needs
I need to display an image, which I've done without problems before, but today
I display set of images(small). I need to show the larger image(300*300) at some
I need to display image and one button on fancybox popup but I can't
I need to display image and text in my listview when i click a
I need to resize an image to display on different pages in different sizes,
I need to display array of images in a single view which have various
I have a custom asp.net server control to display images.What I need now is
I use Safari to browse the net, i need to display an image as
I need to display image that is in file system not in project directory

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.