• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

image dimensions

 
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an image, onload of which I have to check if the width and height are 1 pixel and if yes, I change the src attribute in a function.
Now, my problem is I need to load the images always with width and height = 20 say. Now i cannot give the width and height attributes in the tag itself, becos then I would lose my way to differentiate the 1-pixel image...
Now if I set these attributes in the function itself, then the image gets loaded first with its correct dimesions and then changes it. So i get a flickering effect (I load many images like way), which I should avoid.
Sounded very simple at the beginning, but I got stuck. I cannot set the width+height attribute in the tag, and if I set in the function, I get this flickering effect. Any ideas??
Shankar
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I think is happening:
The reason for the flicker is that the image is getting reloaded.
Solution:
Might want to try a preloader script
or you might want to try to load the images off of the page with that size.
Or you can give the images an extra attribute tag so you can teg which images are the ones that you need to change.
Eric
 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think the images are not getting reloaded.
the problem is i cannot specify width+height in the img tag becos I need to do something in my javascript based on the actual dimensions. Now since I dont specify the dimensions, space is allocated when the page is loaded for all my images(10 in a row).Now when the page has been loaded, the onload function gets called where I check the dimensions, do something according to my requirements, AND then I change the dimensions. This is the cause for the flicker......
You mentioned adding an extra attribute, I am not quite sure if that will work either. Reason, I need to change the dimensions of ALL my images, and change the src attribute of ANY image that has a dimension 1-pixel.
Regards
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic