21305 Posts in 5736 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 434 Views |
-
$gd->writeTo function

6 October 2010 at 6:45am Last edited: 6 October 2010 8:47am
I'm looking for more information on writeTo() function. I want to be able to change the names of resampled images for SEO purposes and I'm wondering how to properly set the the writeTo function on an extended image class:
function generateSmallimage($gd) {
$gd->writeTo("this.jpg");
$gd->resizeRatio(150,150);
return $gd;
}The class documentation doesn't provide much direction on the actual use of the function.
EDIT
After a little more playing around with code pulled from the IMage Object I've gotten this far
function generateSmallimage($gd) {
//Get asset Folder
$folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/";
//Get Current Filename
$filename = $this->Name;
//Get Extension
$ext = strtolower(substr($filename, strrpos($filename,'.')+1));
//set new path and filename;
$newFilename = $folder . "_resampled/my-file-name." . $ext;
$smallImage = $gd->resizeRatio(150,150);
$smallImage = $smallImage->writeTo($newFilename);
return $smallImage;
}This will generate a resized image in the correct folder, but it still returns a link to a filename titled smallImage-originalFilename
Cheers,
| 434 Views | ||
|
Page:
1
|
Go to Top |

