Can't get im->create working
Permalink
Hi!
I've a quesion about the image helper caus I can't get it work right.
I'm trying to create a thumbnail of an image without having the image object.
So i found $im->create to be usefull, but i can't get it to work.
from:http://www.concrete5.org/documentation/developers/files/helpers/...
With the code below i'm trying to make a thumbnail, but nothing happends?
What am i doing wrong?
I working on Concrete5.6.0.1
I hope someone can help me
Much appreciated.
Ray
I've a quesion about the image helper caus I can't get it work right.
I'm trying to create a thumbnail of an image without having the image object.
So i found $im->create to be usefull, but i can't get it to work.
$im->create($originalPath, $newPath, $width, $height)
from:http://www.concrete5.org/documentation/developers/files/helpers/...
With the code below i'm trying to make a thumbnail, but nothing happends?
What am i doing wrong?
<?php $originalPath = "http://www.hometrainer.nl/nieuw/loopbanden/tunturi-pure-run-60/"; $newPath = "files/cache/"; $width = 225; $height = 250; $thumbnail = $im->create($originalPath, $newPath, $width, $height); echo $thumbnail; ?>
I working on Concrete5.6.0.1
I hope someone can help me
Much appreciated.
Ray
Hi Brain,
Thanks for you help.
I'm curious what kind of value needs to be in $crop? Couldn't find that here:http://www.concrete5.org/documentation/developers/files/helpers/...
Maybe you can help with the following code, can't get it to work.
Do you know what i am doing wrong? I even get a fatal error, (Fatal error: Call to undefined method BlockView::create())
I hope you can help, much appreciated
Thanks for you help.
I'm curious what kind of value needs to be in $crop? Couldn't find that here:http://www.concrete5.org/documentation/developers/files/helpers/...
Maybe you can help with the following code, can't get it to work.
Do you know what i am doing wrong? I even get a fatal error, (Fatal error: Call to undefined method BlockView::create())
$im = Loader::helper('image'); $path = "/nieuw/files/8713/5533/0838/tun-pure-row.jpg"; $originalPath = dirname($path); //| /nieuw/files/8713/5533/0838 $filename = basename($path); //| tun-pure-row.jpg $maxWidth = 225; $maxHeight = 250; $crop = 1; if (!file_exists(DIR_FILES_CACHE . '/' . $filename)) { // create image there $this->create($originalPath, DIR_FILES_CACHE . '/' . $filename, $maxWidth, $maxHeight, $crop); }
I hope you can help, much appreciated
I've have it almost working thanks to help earlier.
The below code works flawless, only the image isn't created.
Do you know what's wrong?
folder premissions of files and below is 777.
Got any idea?
Much appreciated
The below code works flawless, only the image isn't created.
Do you know what's wrong?
folder premissions of files and below is 777.
Got any idea?
<?php $fh = Loader::helper('file'); $im = Loader::helper('image'); $prefix = 'prefix'; $originalPath = 'http://www.hometrainer.nl/nieuw/loopbanden/tunturi-pure-run-60/'; $maxWidth = 225; $maxHeight = 250; $cacheFolder = DIR_FILES_CACHE; $newFileName = md5($prefix . $originalPath . ':' . $maxWidth . ':' . $maxHeight . ':') .'.'. $fh->getExtension($path); if (!file_exists(DIR_FILES_CACHE . '/' . $newFileName)) { $im->create($originalPath, DIR_FILES_CACHE . '/' . $newFileName, $maxWidth, $maxHeight); } echo "<img src='".DIR_FILES_CACHE . '/' . $newFileName ."' alt='new image'/>"; ?>
Much appreciated
This a sample how Concrete5 core generated a $newFileName, but you can use your own may of doing this:
This is a example how you should use the function: