Complemento de miniaturas en combinación con smarty

I'm currently using this library to generate thumbnails

http://phpthumb.gxdlabs.com/

What I want to do is, to show all images I got in a thumbnail, so they have the same size etc. What I did was this

$getAllImages = glob("images/profile/" . $db->getUserID($_SESSION['username']) . "/*.*");
$options = array('resizeUp' => true, 'jpegQuality' => 80);
$arr = array();
for($i = 0; $i < sizeof($getAllImages); $i++)
{
    $thumb = PhpThumbFactory::create($getAllImages[$i], $options);
    array_push($arr, $thumb);
}
$smarty->assign('images', $arr);

I guess the error is clear, $thumb is an object and cannot be used by smarty. My smarty code currenty is this

{foreach from=$images item=res}
<div id={$res} class="imageShow">
<a href="{$res}" class="fancybox" rel="gallery"><img src="{$res}" ></a><br>
<input type="button" name="activatePic" id="activatePic" onclick="activatePic('{$res}' , {$userid})" value="Use as profile picture">
</div>
{/foreach}

And this is the error message I'm getting

 Catchable fatal error: Object of class GdThumb could not be converted to string in F:\xampp\htdocs\FinalYear\smarty\templates_c\11edc15b4981ef4097a5734dbbaa613df53386a9.file.myPhotos.html.php on line 119

How can I convert or use the $thumb variable in order to fill in the array and use it in the html page in the foreach-loop?

preguntado el 05 de mayo de 13 a las 18:05

1 Respuestas

You're trying to output the image in the middle of the html code. I don't think you can do that with this library, or even if you could, it would be a waste of resources and bandwidth. If you follow the instructions at https://github.com/masterexploder/PHPThumb/wiki/Basic-Usage#showing-images, then your smarty code should look something like:

<img src="show_image.php?file={$path_and_original_image_name_here|escape:'url'}"/>

It's still not the best method (you probably should add restrictions, caching, more parameters...) but it's a start

contestado el 08 de mayo de 13 a las 10:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.