Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38652

Re: missing image error

From James Kirk <noneya.invalid@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: missing image error
Date 2020-08-04 22:38 -0400
Organization Time Travel Tracing
Message-ID <20200804223822.48ab12d7@james.kirk.invalid> (permalink)
References <mICdnUE2Q-twd7XCnZ2dnUU7-fvNnZ2d@westnet.com.au> <hoskjfFefplU1@mid.individual.net>

Show all headers | View raw


In Message: <hoskjfFefplU1@mid.individual.net>
Arno Welzel <usenet@arnowelzel.de> wrote:

> Andrew Poulos:

>> I'm dynamically adding images to a page using

[snip]

>> and the page works as expected. That is, when the image is not
>> available 'imagenotfound' is shown in its place.

>> The client tests the page with the console open and each time an
>> image is unavailable they see a 404 error. I've tried explaining
>> that it needs to error before it can know to replace it with
>> 'imagenotfound' but they would prefer that image's 404 error not
>> show.

>> Is there a way to trap the 404 so it doesn't show in the console?
>> Or is there some other way I can try to get the image and thereby
>> be able to trap the 404?  

> No. That's the reason why there is a console - to see what is going
> on. Without trying to load an image and getting the 404 error the
> "onerror" attribute would not work at all.

> The only way to avoid 404 errors would be a wrapper script on the
> *server* which will either return the actual image or a placeholder
> if the image can not be loaded:

> <img src="server-side-loader?image=myimage.jpg" ...>

> Where "server-side-loader" is a PHP script etc. which will try to
> load the specificed image file and if this is not possible return
> the placeholder.

š¬šžš«všžš« šœšØš§šŸš¢š š®š«ššš­š¢šØš§ 

   RewriteCond %{REQUEST_FILENAME} !-f 
   RewriteCond %{REQUEST_URI} /img/.*\.(jpg|png|svg)$ [NC]
   RewriteRule . /img/funnyClown.jpg [L]

If the server generates a listing.

  Scrape the index for image links, then check images links for a
  match.



-- 
Jš•’š•žš•–š•¤ š•‚š•šš•£š•œ

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

missing image error Andrew Poulos <ap_prog@hotmail.com> - 2020-08-04 14:58 +1000
  Re: missing image error Arno Welzel <usenet@arnowelzel.de> - 2020-08-04 10:29 +0200
    Re: missing image error James Kirk <noneya.invalid@gmail.com> - 2020-08-04 22:38 -0400
      Re: missing image error Arno Welzel <usenet@arnowelzel.de> - 2020-08-05 07:49 +0200
  Re: missing image error Julio Di Egidio <julio@diegidio.name> - 2020-08-04 02:18 -0700
    Re: missing image error Andrew Poulos <ap_prog@hotmail.com> - 2020-08-05 13:20 +1000
  Re: missing image error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-05 08:44 +0200
    Re: missing image error Andrew Poulos <ap_prog@hotmail.com> - 2020-08-05 18:02 +1000
      Re: missing image error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-05 10:18 +0200
      Re: missing image error Julio Di Egidio <julio@diegidio.name> - 2020-08-05 02:36 -0700

csiph-web