SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Substitute for getimagesize function?

    I have an image display script based on the getimagesize function that works great - but only if the images are on the same site. I'm trying to link several "satellite" websites to a central image repository, and my script doesn't work. (I remember someone telling me that getimagesize doesn't work for remote connections, even if the two websites are hosted on the same server.)

    So I wondered if there might be some sort of substitute for getimagesize that does work with remote connections. Alternatively, is it really necessary to include an image's dimensions (height and width) in your html? It would be nice to at least somehow gauge the width, because I also use my getimagesize script to display my images in div's (<div>) of the same width.

    Thanks.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    getimagesize does work on remote images I just tried it on the sitepoint logo. course it might just be settings on my server.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    getimagesize does work on remote images I just tried it on the sitepoint logo. course it might just be settings on my server.
    When you use it on the sitepoint logo, what value do you use for $_SERVER['DOCUMENT_ROOT'] ?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what exactly are you using getimagesize for? to size the image tag? why don't you not define the width/height of the tag and let the image automaticly size itself?

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geosite View Post
    When you use it on the sitepoint logo, what value do you use for $_SERVER['DOCUMENT_ROOT'] ?
    PHP Code:
    <?php

    $g 
    getimagesize('http://sitepointstatic.com/images/new/logo.gif');

    var_dump($g);
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RetoxMedia View Post
    what exactly are you using getimagesize for? to size the image tag? why don't you not define the width/height of the tag and let the image automaticly size itself?
    Here's an example of how I'm using my original getimagesize script:

    http://www.geosymbols.org/World/Arizona/Flower

    I have many hundreds of pages that will eventually have pictures of state flowers, state trees, national or state flags and on and on. So rather than code each image, I simply created a script that automatically displays the appropriate image if it exists. For example, I might have a folder named state_flowers, and if I dump an image named AZ.gif or AZ.jpg in that folder, it will display on the Arizona State Flower page. If I insert an image AZ2.gif or AZ2.jpg, it displays, too.

    However, the page I referenced above links to an image on the same site. I couldn't get it to work remotely, so I had to move the images to the same site.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, i still fail to see what getimagesize() has to do with that but display the size of the image...

  8. #8
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    PHP Code:
    <?php

    $g 
    getimagesize('http://sitepointstatic.com/images/new/logo.gif');

    var_dump($g);
    Wow, that looks totally unfamiliar to me. Where does the "static" in sitepointstatic.com come from?

    Or, better yet, what value would you use to link to this image?:

    http://www.geosymbols.org/images/GS/.../na/usa/az.jpg

    If I can figure out how to make my script work remotely, then I'll move the image to...

    http://www.geobop.org/images/GS/plan.../na/usa/az.jpg

    I have to go to work now, but I'll try and figure out how to merge your script with mine in the morning. Thanks for the tip.

  9. #9
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RetoxMedia View Post
    hmm, i still fail to see what getimagesize() has to do with that but display the size of the image...
    There are two things:

    1) Display the size of the image - if necessary. I think I asked earlier if it's really necessary to display an image's size. If you DON'T display an image's size, it generally displays at the proper size anyway (I think), but does it violate any "rules" I should know about?

    2) Some of my images also include captions, which are enclosed in div or span tags that should ideally match the size of the image. So if I know the image's width, I can then automatically display a div or span that matches that width.

    FYI: The script I'm working on at the moment probably won't display more than a few hundred images, and many will be the same size, so I could code some of this stuff manually. But if I can get all the relevant data remotely, then I can apply it to some bigger scripts I still need to make.

    Thanks.

  10. #10
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geosite View Post
    Or, better yet, what value would you use to link to this image?:

    http://www.geosymbols.org/images/GS/.../na/usa/az.jpg

    If I can figure out how to make my script work remotely, then I'll move the image to...

    http://www.geobop.org/images/GS/plan.../na/usa/az.jpg
    Sheez, I just discovered that the image I referenced above IS hosted on the remote site. Sorry for all the confusion. I'm not sure why my newer script isn't working, but I'll experiment with it some more tomorrow.

  11. #11
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geosite View Post
    There are two things:

    1) Display the size of the image - if necessary. I think I asked earlier if it's really necessary to display an image's size. If you DON'T display an image's size, it generally displays at the proper size anyway (I think), but does it violate any "rules" I should know about?

    2) Some of my images also include captions, which are enclosed in div or span tags that should ideally match the size of the image. So if I know the image's width, I can then automatically display a div or span that matches that width.

    FYI: The script I'm working on at the moment probably won't display more than a few hundred images, and many will be the same size, so I could code some of this stuff manually. But if I can get all the relevant data remotely, then I can apply it to some bigger scripts I still need to make.

    Thanks.
    ah ok, thanks for clarifying that for me...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •