How do I display a dynamically resized image in Kohana without saving it?
-
05-07-2019 - |
Question
I have an image path string stored in a database
It goes like: img/uploads/imagename.jpg
I have a controller:
$this->image = new Image($wines->image)
//this is assuming that I have a wines table with the image property
$this->image->resize(60, 250, Image::AUTO)
echo $this->image->render();
//the problem is nothing is rendered
//Is there a better way of doing this? the image path that I am passing at the Image object //instantiation is the result of a query
No correct solution
OTHER TIPS
- Don't use "echo"
- Move the render to a view
You need not use the echo itself. render() itself echoes the output to the browser. Maybe, you need to use render(true), as per the document. http://docs.kohanaphp.com/libraries/image#render
EDIT: Also be careful with the paths. If possible, use absolute paths OR preferably paths relative to your document root.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow