/** * Create and save a preview of an uploaded image. * @param {ae_MediaModel} $m The media model of the image. */ protected function createImagePreview(ae_MediaModel $m) { $path = $this->mediaPath . $m->getFilePath(); $previewPath = explode('/', $path); array_pop($previewPath); array_push($previewPath, 'tiny', $m->getName()); $previewPath = implode('/', $previewPath); try { $img = new ae_Image($path, $m->getType()); } catch (Exception $exc) { return FALSE; } $img->resize(IMAGE_PREVIEW_MAX_WIDTH); $img->saveFile($previewPath); }
public function testSetName() { $m = new ae_MediaModel(); $m->setName('my comment filter'); $this->assertEquals($m->getName(), 'my comment filter'); $m->setName(4); $this->assertTrue($m->getName() === '4'); $m->setName('should/not/be/a/path.png'); $this->assertEquals($m->getName(), 'should-not-be-a-path.png'); $m->setName('should\\not\\be\\a\\path.png'); $this->assertEquals($m->getName(), 'should-not-be-a-path.png'); $this->setExpectedException('Exception'); $m->setName(''); }