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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:00:17+00:00 2026-06-11T22:00:17+00:00

I’m developing an image hosting website, mainly just to learn the ropes, and I’m

  • 0

I’m developing an image hosting website, mainly just to learn the ropes, and I’m using php and mysql, as well as html, css, and javascript.

As it is, on an image page, it loads up the full-size image, and the squishes it into a box in the layout. I get that that isn’t the right thing to do; I should be sending the image that is already the right size. But here’s the trouble: the box that the image is resized to fit into is based on the browser window’s size. So it’s a larger image if the page is larger, and a smaller image if the page is smaller.

One solution I thought of would be to store the image in several different sizes, then use javascript on the page to determine the window size, then the box’s size, and then use that information to choose the right image to load. But all that inline javascript seems like it would slow things down a lot as well.

What’s the best solution for this?
What if the only thing I’m aiming for is speed?
What if I have limited space to store multiple sizes of images?
What if I have limited computing power?

I’m trying to learn about this stuff; not just implement it. Indecisive answers that analyse various options would be great.

  • 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-11T22:00:18+00:00Added an answer on June 11, 2026 at 10:00 pm

    You should be able to detect the window size in JavaScript before the document even loads, so the would really be no performance hit in assessing the window sizing and then loading the proper image (which would have been a second request anyway). You should just check the window size, create a single PHP script which takes the desired image size, and then use that to pull in the proper image after the document is loaded by attaching arguments to the img src attribute. Really no matter how you do it along those lines the performance impact will be insignificant since images are by default distinct requests and that will be your bottleneck.

    If you have limited space and a lot of images you could use PHP to dynamically create the image per request (with adjusted caching). If you had limited computing power you’d want to cache more heavily or you could have the images pre-made if you have a small set of possibilities. Alternately you could have certain “milepost” types of images since image resampling with a large variance normally has to be done in multiple passes, so each milepost could allow for fewer passes to sample down to the desired exact size.

    If transfer speed was theoretically a major concern you could also use image slicing. Since most clients will allow for 2+ consecutive connections to the same host you could split the image if it was large enough to warrant it (offsetting the cost of request initiation) and then display the sections merged on the page (kind of like multiplexing).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,

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.