httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <cs...@fx.ro>
Subject RE: [users@httpd] Configure to send jpg images with HTML around them?
Date Wed, 16 Jul 2003 12:57:19 GMT
> -----Original Message-----
> From: Brian Dessent [mailto:brian@dessent.net]
> Sent: Wednesday, July 16, 2003 3:33 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Configure to send jpg images with HTML around
> them?
>
>
> csebe@fx.ro wrote:
> >
> > The simplest approach that comes to mind would be to use a simple HTML
> > wrapper server side program (CGI, PHP, etc). This program, let's call it
> > imagewrapper.cgi, should receive the image name as a parameter
> and return it
> > wrapped in some minimal html to the browser like:
> >
> > <html>
> > <body>
> > <img src="foo.jpg">
> > </body>
> > </html>
> >
> > Then you should change all your existent click-able links to
> something like:
> > <a href="imagewrapper.cgi?img=foo.jpg"><a>
>
> I think (not sure) that the original poster wanted this to happen from
> Apache-generated directory listings of files... in which case you'd just
> need to augment the above with a mod_rewrite rule to turn requests
> ending in "\.(jpe?g|gif|png|tiff?|bmp|whatever)" to a call to this CGI.
>
> Brian
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

With or without Apache-generated directory listing, using mod_rewrite seems
indeed more elegant since no html should be modified to add the
href="imagewrapper.cgi?..."

However, this approach might fail if the same images would be *also*
requested to be displayed inline in some html pages, and not only
standalone. In this case the cgi program will wrap the image in HTML anyway,
and some strange things would occur.
You'd need a mechanism to decide if an image was requested as part of a page
=> don't wrap it, or as standalone => wrap it. I don't think this can be
done since the browser launches the requests for images perfectly
independent...

As said, using mod_rewrite is more elegant, but the final solution depends
on the OP's setup.

Cheers,

Lian Sebe, M.Sc.
Freelance Analyst-Programmer
www.programEz.net


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message