Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    ABW Ambassador Doug247's Avatar
    Join Date
    January 18th, 2005
    Location
    DE USA
    Posts
    931
    How to handle broken images?
    IS there a code snipet that will load a friendly 'sorry no image' image of the affiliate datafeed Image_Url does not have any image?

    I hate broken images.

    Thanks,
    Doug

  2. #2
    Super Sh!t Stirrer SSanf's Avatar
    Join Date
    January 18th, 2005
    Posts
    9,944
    Can't you just put your own "no image" image in the feed?
    Comments are opinion unless otherwise noted. Remember, pillage first. Then burn. Half of all people in the world have IQs under 100. You best learn to trust ol' SSanf!

  3. #3
    Lite On The Do, Heavy On The Nuts Donuts's Avatar
    Join Date
    January 18th, 2005
    Location
    Winter Park, FL
    Posts
    6,930
    Or, if the images are all the same size, use a default "no image" image as a background image so it'll show whenever nothing loads over it. Also can use z-index within css to accomplish the same thing.

  4. #4
    ABW Ambassador Doug247's Avatar
    Join Date
    January 18th, 2005
    Location
    DE USA
    Posts
    931
    Quote Originally Posted by SSanf
    Can't you just put your own "no image" image in the feed?

    I'm talking if the image on the merchant side is not there. I think the ZIndex thing should work I'll have to try that

    Thanks,
    Doug

  5. #5
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Handling Broken Images
    Found this while thread while searching.

    Quote Originally Posted by Donuts
    Or, if the images are all the same size, use a default "no image" image as a background image so it'll show whenever nothing loads over it. Also can use z-index within css to accomplish the same thing.
    My images are all 60x60. So where would the background image go? Within a table cell? (I know how to do that) But I have text above and below each image in the cell - Do I need a separate cell for the image?

    Thanks for any help.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  6. #6
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Just tried the cell background trick. It now displays both the "No Image" background GIF and the ugly missing image alert. So that will not work.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  7. #7
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    if you are talking on the merchant side then I don't know what you can do.

    A good possible long term strategy is to suck down those images to your server. You can then double check the feed against what you have. And make filler images with your brand that say 'No Image Available'.
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  8. #8
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Wink
    Put the following code on your pages.

    In the head put:

    Code:
    <SCRIPT LANGUAGE="Javascript">
    <!-- 
    function CheckImages()
    {
    var Imgs = document.getElementsByTagName("img");
    var intNumofImgs = Imgs.length;
    for ( var i = 0 ; i < intNumofImgs ; i++ )
    {
    if (Imgs[i].complete == false)
    Imgs[i].style.visibility='hidden';
    }
    }
    // -->
    </SCRIPT>
    Change the <body tag to:

    Code:
    <BODY onLoad="CheckImages();">
    When the computer loads the page it checks the page to see if all of the images are there.

    If an image is missing it just shows a blank space on the page that is the same color as the background where the image was.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  9. #9
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    This is a php-based page. I am thinking there is a function to test the link and replace the URL if needed.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  10. #10
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Wink
    The above code will work in a php page.

    I use it on my php sites.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  11. #11
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    Ack... doesn't that really get every image twice - Once in the HTML and once in the Javascript.
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  12. #12
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Talking
    You don't see any difference in page load speed.

    It probably checks the images as they are being loaded to the computer so it is really just seeing them once.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  13. #13
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Thanks BurgerBoy! This works in my IE browser, but not in FF nor Netscape.

    But I will take a 75% solution over nothing! I have searched far and wide and this is the first thing that has worked.

    Check your pages in FF and let me know if it is working for you.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  14. #14
    Moderator BurgerBoy's Avatar
    Join Date
    January 18th, 2005
    Location
    jacked by sylon www.sylonddos.weebly.com
    Posts
    9,618
    Talking
    I've never used anything but IE.

    In my web stats the vistors to my sites are usually around 95% IE.

    So, That will cover just about all of my vistors.

    Quit a few of my employees go to Murray State University here.

    Some are taking computer science courses.

    I told one of them what I want to do and this is what he came up with.

    It was free so I thanked him and used what he came up with.

    Vietnam Veteran 1966-1970 USASA
    ABW Forum Rules - Advertise At ABW

  15. #15
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    What I do is send the URL to each image through my image caching script. For example:

    <img src='/image.php?url=http://www.merchant.com/image.jpg'>

    Then image.php will download the image to my server, resize if necessary and store it locally for a few days. If no image was downloaded I just show a "No Photo Available" image. I maintain a database of image URLs so I can check if the image is already cached, needs to be re-cached or needs to be added to the cache. It works really well since all the images are coming from my server.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  16. #16
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by Cheesehead
    This is a php-based page. I am thinking there is a function to test the link and replace the URL if needed.
    I deal with a no image problem, in one of these two ways.

    If the records missing the Thumbnails don't have enough product description, I may just auto-delete those records on the datafeed import script, before the:
    mysql_query("ALTER TABLE $temptable RENAME $maintable") or die(mysql_error());

    mysql_query ("DELETE from $temptable WHERE Thumbnail Like ''");
    mysql_query("OPTIMIZE TABLE $temptable") or die(mysql_error());
    mysql_query("drop table $maintable");
    mysql_query("ALTER TABLE $temptable RENAME $maintable") or die(mysql_error());
    That way, I will get no missing Thumbnails on any page, because any record without Thumbnail will not be included on the $maintable.

    Also, sometimes I just do this instead, on the individual pages script:

    if ($Thumbnail == "")
    {
    echo "<img src=\"/images/noima.gif\" width=\"75\" height=\"75\" border=\"0\">";
    } else {
    echo "<a href=\"".$Link."\" target=\"_new\"><img src=\"$Thumbnail\" width=\"75\" border=\"0\"></a>";
    }
    Where noima.gif is a small image on my server, that will show up only IF there is no Thumbnail for that record on the datafeed.

  17. #17
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    I love ABW.

    Snib's solutions seems the slickest here. You are not relying on a resource from somebody else's server then. That is always a risk - hoping that somebody will have something on their server. He solves that by not relying on their server. Brilliant!

    Patrick
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  18. #18
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by patrick24601
    I love ABW.

    Snib's solutions seems the slickest here. You are not relying on a resource from somebody else's server then. That is always a risk - hoping that somebody will have something on their server. He solves that by not relying on their server. Brilliant!
    Thanks Patrick!

    But I do rely on their server to get the image every time I update my cache. Each image has a certain number of days before I'll grab it again.

    Sal,

    Your solution only works if the merchant doesn't provide an image URL. But what about those image URLs they do provide that don't work?

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  19. #19
    More Cheesier Than Ever Cheesehead's Avatar
    Join Date
    January 18th, 2005
    Location
    Land of The NFL Champs!
    Posts
    2,942
    Thanks BurgerBoy, Snib, and Mr. Sal. I didn't mean to slam your solution BurgerBoy - I just checked and about 90% overall are using IE these days. Like I said, something that works for nearly all people is far better than what I had (nothing). And the price was right!

    I will look into Snib's and Mr. Sal's solutions as well.
    This World is Not My Home
    We're gonna go inside, we're gonna go outside, inside and outside. . . And then we're gonna go go go and we're not gonna stop til we get across that goalline! Quotes from the movie Rudy, 1993

  20. #20
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by Snib
    Sal,

    Your solution only works if the merchant doesn't provide an image URL. But what about those image URLs they do provide that don't work?

    - Scott
    Well, if while I am checking the output from the datafeed I find a bad image URL that they do provide but, that doesn't work, I have a few ways to handle that issue.

    If when I click on that bad image, it lands on a good image on the merchant site, I just replace the URL on my page to the good one on the spot, or just wait for the next new datafeed reload to see if they fix the error on the new feed. (It depends on how often they upload new feeds.)

    If there are just a couple of bad images URL, I may use another IF-statement on the script, but if they have too many of those errors, and they don't fix it by the next couple of feed updates, I may just block that category from showing up, and if, the error is on more than one category, and on every new feed update, I may just replace that merchant with a more reliable one, if there is a equivalent replacement.





    I like to use the conditional statements a lot:
    If Links are Green: Links are ready to GO.

    If Links are Yellow: Links may get to be Replaced.

    If Links are Red: Links may get to be Deleted.

    Else: ==





  21. #21
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    You can handle this in php:

    Simply use fopen() and fread() to get the file contents then use the image function $img=@imagecreatefromstring($data).

    This function returns false if the resource is not a valid image. So if it is false
    use $img =imagecreatefromjpeg("noimgage.jpg");

    Then you can resize the picture and use the imagejpeg() to display the image.

    Pm sent to cheesehead with demo url.

  22. #22
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by Mr. Sal
    If when I click on that bad image, it lands on a good image on the merchant site, I just replace the URL on my page to the good one on the spot, or just wait for the next new datafeed reload to see if they fix the error on the new feed. (It depends on how often they upload new feeds.)

    If there are just a couple of bad images URL, I may use another IF-statement on the script, but if they have too many of those errors, and they don't fix it by the next couple of feed updates, I may just block that category from showing up, and if, the error is on more than one category, and on every new feed update, I may just replace that merchant with a more reliable one, if there is a equivalent replacement.
    These are all very high maintenance solutions. They require that you look over all the data every time you import it into your database. For those of us who update hundreds of thousands of products daily this just won't cut it.

    Quote Originally Posted by Donk
    Simply use fopen() and fread() to get the file contents then use the image function $img=@imagecreatefromstring($data).

    This function returns false if the resource is not a valid image. So if it is false
    use $img =imagecreatefromjpeg("noimgage.jpg");

    Then you can resize the picture and use the imagejpeg() to display the image.
    This is similar to my solution, but you need to check the mime type of the image to see if it's a gif or a jpg. Then you need to either use imagecreatefromjpeg or imagecreatefromgif. Resizing isn't trivial either as you need to consider the width and height ratio of the image. Also unless you cache the resized image this will increase your image load times.

    Sorry to put a damper on everybody's solution! All of these will work to some degree, but some are more practical than others.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  23. #23
    Full Member
    Join Date
    October 22nd, 2006
    Posts
    200
    Quote Originally Posted by Snib
    check the mime type of the image to see if it's a gif or a jpg. - Scott
    No you dont.

    Quote Originally Posted by Snib
    Resizing isn't trivial either as you need to consider the width and height ratio of the image.- Scott
    Yes it is.

    Simply create a new image then calculate the original height and width using imagesx($img) and imagesy($img). Use that ratio to work out the offset required to centralise the image.

    PHP Code:
    $width=imagesx($img);
    $height=imagesy($img);
    if ((
    $width/$height)>1){
    //wide image
    $newwidth=100;
    $newheight=round(100*$height/$width,0);
    $xoffset=0;
    $yoffset=round((100-$newheight)/2,0);
    }
    else
    {
    //tall image
    $newheight=100;
    $newwidth=round(100*$width/$height,0);
    $xoffset=round((100-$newwidth)/2,0);
    $yoffset=0;
    }
    $newpic=imagecreatetruecolor  100,  100 );
    $white=imagecolorallocate($newpic,255,255,255);
    imagefill($newpic,0,0,$white);
    imagecopyresampled($newpic,$img,$xoffset,$yoffset,0,0,$newwidth,$newheight,$width,$height); 
    regards Bob

  24. #24
    Full Member
    Join Date
    March 10th, 2006
    Posts
    466
    Quote Originally Posted by Snib
    What I do is send the URL to each image through my image caching script. For example:

    <img src='/image.php?url=http://www.merchant.com/image.jpg'>

    Then image.php will download the image to my server, resize if necessary and store it locally for a few days. If no image was downloaded I just show a "No Photo Available" image. I maintain a database of image URLs so I can check if the image is already cached, needs to be re-cached or needs to be added to the cache. It works really well since all the images are coming from my server.

    - Scott
    I do the same thing, but two weeks ago, I moved servers within the same hosting company. Only this weekend I discovered there is a problem where cached file names are being written, but there is no data in the file, i.e no image, bytes = 0.

    Anyway, I was wondering if off-hand anyone might know why file names are being written to my cache directory but the image data is not. It was working fine and I made no code changes, I simply moved servers to a less busy shared server. The cache directory permissions are set to 777 - at least for now. I'm sure it is something server side that is the problem, because the code was working fine before the move.

    The hosting tech support is unpredictable and depends largely on who answers the phone, and is usually my last resort.

  25. #25
    http and a telephoto
    Join Date
    January 18th, 2005
    Location
    NYC
    Posts
    17,708
    Where do you get the 90% stat for IE users? I see a consistent 20-25% are using FF, and 5% using other browsers. So 70-75% use IE. Which is significant, but FF is gaining and needs to be supported or you are losing a lot of potential income.

    Patrick, affiliates sucking down the images and hosting them might work for stable merchants, but those are the ones that don't have image problems anyway. For many merchants hosting the images locally is against the TOS, CafePress for instance. And for other merchants, they may update images frequently and the wrong image could be what the affiliate is serving up.
    Deborah Carney
    TeamLoxly.com BookGoodies.com ABCsPlus.com

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. How Do You Handle Missing Images & Bad Landing Pages?
    By ChgoWriter in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: January 31st, 2013, 01:49 PM
  2. Broken Ad Images
    By BurgerBoy in forum Midnight Cafe'
    Replies: 45
    Last Post: March 17th, 2010, 01:14 PM
  3. Broken Images
    By mobilebadboy in forum Midnight Cafe'
    Replies: 5
    Last Post: April 27th, 2007, 03:55 AM
  4. Broken images
    By Haiko de Poel, Jr. in forum Midnight Cafe'
    Replies: 2
    Last Post: February 27th, 2003, 06:30 PM
  5. Broken images
    By Haiko de Poel, Jr. in forum Midnight Cafe'
    Replies: 1
    Last Post: January 6th, 2003, 07:38 PM

Posting Permissions

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