/** * Delete unit image * * @param string $filename * @return boolean */ public function deleteImageFiles($filename) { $extensionMediaFolder = $this->getFolder(); $files = array(); $files[] = $unitFolder . DIRECTORY_SEPARATOR . $filename; $files[] = $unitFolder . DIRECTORY_SEPARATOR . RM_Media_Image::get(RM_Media_Image::THUMB)->createFilename($filename); return RM_Filesystem::deleteFiles($files); }
/** * Resize all thumbnails for a unit. */ public function resize() { RM_Media_Image::initialize(); $model = new RM_UnitMediaFiles(); $files = $model->get($this->_unit); foreach ($files as $file) { $this->createThumbnail($file->filename); } }
/** * Initialize all objects at a first time, or if config has been changed. */ public static function initialize() { self::$_list = array(); $adminThumbnail = new RM_Media_Image(); $adminThumbnail->_postfix = self::ADMIN; $adminThumbnail->_width = 100; $adminThumbnail->_height = 100; $adminThumbnail->_quality = 100; $adminThumbnail->_keepAspect = true; self::$_list[self::ADMIN] = $adminThumbnail; $config = new RM_Config(); $thumbnail = new RM_Media_Image(); $thumbnail->_postfix = self::THUMB; $thumbnail->_width = $config->getValue('rm_config_image_thumb_settings_x_res'); $thumbnail->_height = $config->getValue('rm_config_image_thumb_settings_y_res'); $thumbnail->_quality = $config->getValue('rm_config_image_thumb_settings_quality'); $thumbnail->_keepAspect = (bool) $config->getValue('rm_config_image_thumb_settings_aspect'); self::$_list[self::THUMB] = $thumbnail; $main = new RM_Media_Image(); $main->_postfix = self::MAIN; $main->_width = $config->getValue('rm_config_image_settings_x_res'); $main->_height = $config->getValue('rm_config_image_settings_y_res'); $main->_quality = $config->getValue('rm_config_image_settings_quality'); $main->_keepAspect = (bool) $config->getValue('rm_config_image_settings_aspect'); self::$_list[self::MAIN] = $main; }
/** * Resize all thumbnails */ public function resize() { RM_Media_Image::initialize(); $files = RM_Filesystem::getFiles($this->_imageFolder, $this->_extensions); foreach ($files as $filename) { if (RM_Media_Image::isOriginal($filename)) { $this->createThumbnail($filename); } } }