Am 03.07.2007 um 11:20 schrieb Liutauras:

> Hi all!
>
> by this url i can see image in browser: http://www.sitename.lt2/lt/ 
> image
> But i cant include it in Master.php like this:  <img src="<?=
> $ro->gen('image'); ?>" alt="paveiksliuko vieta" /> it is outputed  
> in TOP
> of  the page.. and XML check error accours
>
> my routing:
> <route action="Image" module="Default" name="image"
>       output_type="image_png" pattern="^/image" />

Anchor it at the end, i.e. ^/image$, otherwise that pattern matches / 
image...hax0r etc as well

> output type:
> ...................
> <output_type name="image_png">
>         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/ 
> config)
> xpointer(/a:configurations/a:sandbox/a:renderers)" />
>
>         <xi:include xpointer="xmlns(a=http://agavi.org/agavi/1.0/ 
> config)
> xpointer(/a:configurations/a:sandbox/a:layouts)" />
>
>         <parameter name="http_headers">
>           <parameter name="Content-Type">image/png</parameter>
>      </parameter>
> </output_type>

Remove the renderers and layouts, you don't need those.


> i created this view and tried many of combinations but not working:
> <?php
>
> class Default_ImageSuccessView extends AgaviView
> {
>     public function executeImage_png(AgaviRequestDataHolder $rd)
>     {
> ob_start();
> $im = imagecreatefrompng("redfade.png");
> $image=imagepng($im);
> //ob_get_contents();
> $this->setAttribute('image', $image);
> //ob_end_clean();
>     }
>     public function execute(AgaviRequestDataHolder $rd)
>     {
>     }
> }
> ?>

You should always use a BaseView, and never implement execute()!  
Check the ProjectBaseView that's created by "agavi project" for an  
example and explanations.

That aside, your problem is that you output the return value of  
imagepng, which is a bool.

public function executeImage_png(AgaviRequestDataHolder $rd) {
   $im = imagecreatefrompng('redfade.png');
   ob_start();
   imagepng($im);
   $img = ob_get_contents();
   ob_end_clean();
   return $img;
}

Note that you can also do return fopen('redfade.png'); if you just  
want to output the file, Agavi will fpassthru() it for you.

David





_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to