How can I reuse images from the image gallery?
FYI: I'm having a header with several images that I can set with ImageFields.
These images are set with a Page_Image extends Image class (see code below).
The images in ImageGallery are set with ImageGalleryImage extends Image (see code below).
This way the two conflict: If I use an ImageGallery image in the header, the image won't show up in the gallery. If I use a header image in an album, it gets even transfered from the folder all headerimages are stored in to the specific folder of the album. And off course it won't show up in the header anymore.
That isn't that big a problem, if at least I could get the image from the albumfolder show up both in the header and the album.
from page.php
class Page_Image extends Image {
public function generateMainImage($gd) {
$gd->setQuality(100);
return $gd->croppedResize(400,232);
}
public function generateSubImage($gd) {
$gd->setQuality(100);
return $gd->croppedResize(180,140);
}
public function generateBGImage($gd) {
$gd->setQuality(100);
return $gd->resizeByWidth(801);
}
}
from ImageGalleryImage.php
class ImageGalleryImage extends Image
{
public function generateRotateClockwise(GD $gd)
{
return $gd->rotate(90);
}
public function generateRotateCounterClockwise(GD $gd)
{
return $gd->rotate(270);
}
public function clearResampledImages()
{
$files = glob(Director::baseFolder().'/'.$this->Parent()->Filename."_resampled/*-$this->Name");
foreach($files as $file) {unlink($file);}
}
public function Landscape()
{
return $this->getWidth() > $this->getHeight();
}
public function Portrait()
{
return $this->getWidth() < $this->getHeight();
}
}