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,