You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by RGKärcher <ge...@yahoo.com.ar> on 2007/08/21 17:48:23 UTC

How to display images ?

Hi guys , 

I a new to perl and mod_perl and Apache::Asp , And I
wold like to ask you  How to display an image ? 

I tried the example that display a binary file
included in  /eg , but Is there a simple way to show a
an image ? and I want to show a flash animation also
in my scripts .

I use a code like this in PHP to display an image in
$image variable :

print "	<p><a href=\"http://www.mysite.net/\">  <img
src=\"site_images/$image \"  width=\"160\"
height=\"180\" alt=\"image \" class=\"float-left\"
/></a>\n";

How can I do the same under mod_perl ?

Thanks guys  ,

Rick Karcher



Ricardo german Kärcher

gerkarcher@yahoo.com.ar
german@gnosticos.net
rgkx@imaginator.com


      ____________________________________________________________________________________
¡Sé un mejor fotógrafo!
Perfeccioná tu técnica y encontrá las mejores fotos. Visitá http://ar.yahoo.com/promos/mejorfotografo.html

Re: How to display images ?-Not Working

Posted by Manoj Bist <ma...@gmail.com>.
Hi Rick,

Please use Text::Template for generating the html you send to the client.
As long as you keep appending the html string to $OUT, it should work
under mod_perl2.0.


http://search.cpan.org/~mjd/Text-Template-1.44/lib/Text/Template.pm

Thanks,

Manoj.

On 8/21/07, RGKärcher <ge...@yahoo.com.ar> wrote:
> Hi guys ,
>
> Thanks Michael and Georg but none of the examples
> works   for me ...
>
> I'm using Apache::Asp .
>
> What could be the problem ?
>
> Thanks in Advance
>
> Rick
>
> --- Michael Peters <mp...@plusthree.com> escribió:
>
> > Georg Grabler wrote:
> > > On Tuesday 21 August 2007 15:48:23 RGKärcher
> > wrote:
> > >> print " <p><a href=\"http://www.mysite.net/\">
> > <img
> > >> src=\"site_images/$image \"  width=\"160\"
> > >> height=\"180\" alt=\"image \"
> > class=\"float-left\"
> > >> /></a>\n";
> > >
> > > Perl is just a bit differnt. Either, use ${image}
> > instead of $image or use
> > > sprintf.
> >
> > You can use both of those, but you don't really need
> > to. The above should work
> > just fine. But don't all those escapes of the double
> > quotes give you a headache?
> > There are so many better ways of doing that:
> >
> > print qq|<p><a href="http://www.mysite.net/">
> >   <img src="site_images/$image" width="160"
> > height="180" alt="image"
> >     class="float-left" />
> >   </a></p>
> > |;
> >
> > Having said that, when working with HTML you should
> > really be using templates. I
> > like Template Toolkit
> > (http://search.cpan.org/perldoc?Template) and also
> > use
> > HTML::Template
> > (http://search.cpan.org/perldoc?HTML::Template) but
> > if you're
> > coming from PHP then Mason might be more up your
> > alley
> > (http://search.cpan.org/perldoc?HTML::Mason)
> >
> > --
> > Michael Peters
> > Developer
> > Plus Three, LP
> >
> >
>
>
> Ricardo german Kärcher
>
> gerkarcher@yahoo.com.ar
> german@gnosticos.net
> rgkx@imaginator.com
>
>
>       ____________________________________________________________________________________
> ¡Sé un mejor fotógrafo!
> Perfeccioná tu técnica y encontrá las mejores fotos. Visitá http://ar.yahoo.com/promos/mejorfotografo.html
>

Re: How to display images ?-Not Working

Posted by Clinton Gormley <cl...@traveljury.com>.
On Tue, 2007-08-21 at 14:40 -0300, RGKärcher wrote:
> Hi guys , 
> 
> Thanks Michael and Georg but none of the examples
> works   for me ...
> 
> I'm using Apache::Asp .
> 
> What could be the problem ?
> 
> Thanks in Advance 
> 

What error are you seeing?  What does the HTML being sent to your
browser look like?  What do you see in the apache logs?

The snippet of code that you sent looked correct, so check your
assumptions.  Check that the HTML has the same URL that you are
expecting.  Can you access the image by typing that URL into your
address bar in your browser? Does it produce an error in your apache
log?

If the HTML being produced is correct, then the problem lies outside
Perl.  The image is served by Apache - probably doesn't come near the
Perl (unless you have some authorisation or authentication handlers on
that URL)

Either way, more information would help :)

Clint


Re: How to display images ?-Not Working

Posted by RGKärcher <ge...@yahoo.com.ar>.
Hi guys , 

Thanks Michael and Georg but none of the examples
works   for me ...

I'm using Apache::Asp .

What could be the problem ?

Thanks in Advance 

Rick  

--- Michael Peters <mp...@plusthree.com> escribió:

> Georg Grabler wrote:
> > On Tuesday 21 August 2007 15:48:23 RGKärcher
> wrote:
> >> print " <p><a href=\"http://www.mysite.net/\"> 
> <img
> >> src=\"site_images/$image \"  width=\"160\"
> >> height=\"180\" alt=\"image \"
> class=\"float-left\"
> >> /></a>\n";
> > 
> > Perl is just a bit differnt. Either, use ${image}
> instead of $image or use 
> > sprintf.
> 
> You can use both of those, but you don't really need
> to. The above should work
> just fine. But don't all those escapes of the double
> quotes give you a headache?
> There are so many better ways of doing that:
> 
> print qq|<p><a href="http://www.mysite.net/">
>   <img src="site_images/$image" width="160"
> height="180" alt="image"
>     class="float-left" />
>   </a></p>
> |;
> 
> Having said that, when working with HTML you should
> really be using templates. I
> like Template Toolkit
> (http://search.cpan.org/perldoc?Template) and also
> use
> HTML::Template
> (http://search.cpan.org/perldoc?HTML::Template) but
> if you're
> coming from PHP then Mason might be more up your
> alley
> (http://search.cpan.org/perldoc?HTML::Mason)
> 
> -- 
> Michael Peters
> Developer
> Plus Three, LP
> 
> 


Ricardo german Kärcher

gerkarcher@yahoo.com.ar
german@gnosticos.net
rgkx@imaginator.com


      ____________________________________________________________________________________
¡Sé un mejor fotógrafo!
Perfeccioná tu técnica y encontrá las mejores fotos. Visitá http://ar.yahoo.com/promos/mejorfotografo.html

Re: How to display images ?

Posted by Michael Peters <mp...@plusthree.com>.
Georg Grabler wrote:
> On Tuesday 21 August 2007 15:48:23 RGKärcher wrote:
>> print " <p><a href=\"http://www.mysite.net/\">  <img
>> src=\"site_images/$image \"  width=\"160\"
>> height=\"180\" alt=\"image \" class=\"float-left\"
>> /></a>\n";
> 
> Perl is just a bit differnt. Either, use ${image} instead of $image or use 
> sprintf.

You can use both of those, but you don't really need to. The above should work
just fine. But don't all those escapes of the double quotes give you a headache?
There are so many better ways of doing that:

print qq|<p><a href="http://www.mysite.net/">
  <img src="site_images/$image" width="160" height="180" alt="image"
    class="float-left" />
  </a></p>
|;

Having said that, when working with HTML you should really be using templates. I
like Template Toolkit (http://search.cpan.org/perldoc?Template) and also use
HTML::Template (http://search.cpan.org/perldoc?HTML::Template) but if you're
coming from PHP then Mason might be more up your alley
(http://search.cpan.org/perldoc?HTML::Mason)

-- 
Michael Peters
Developer
Plus Three, LP


Re: How to display images ?

Posted by Georg Grabler <gg...@gmail.com>.
On Tuesday 21 August 2007 15:48:23 RGKärcher wrote:
> print " <p><a href=\"http://www.mysite.net/\">  <img
> src=\"site_images/$image \"  width=\"160\"
> height=\"180\" alt=\"image \" class=\"float-left\"
> /></a>\n";

Perl is just a bit differnt. Either, use ${image} instead of $image or use 
sprintf.

-- 
Yours,
Georg (STiAT)