/** * Delete thumbnails generated for this file by assets * @param $file_id */ protected function _delete_generated_thumbs($file_id) { $thumb_path = Assets_helper::ensure_cache_path('assets/thumbs'); $files = glob($thumb_path . '/' . $file_id . '/*'); if (is_array($files)) { foreach ($files as $path) { @unlink($path); } } }
/** * Returns a path for the thumbnail source * @return mixed */ public function get_thumbnail_source_path() { $path = Assets_helper::ensure_cache_path('assets/s3_sources') . $this->file_id . '.jpg'; if (!file_exists($path)) { $location = $this->get_local_copy(); @rename($location, $path); } return Assets_helper::ensure_cache_path('assets/s3_sources') . $this->file_id . '.jpg'; }
/** * Return the path to the thumbnail * * @param $size * @return string */ public function get_thumb_path($size) { $path = Assets_helper::ensure_cache_path('assets/thumbs/' . $this->file_id); return $path . $this->file_id . '_' . $size . '.' . $this->extension(); }
/** * Perform image actions - resize and save dimensions. If no bucket name provided, $uri is treated as filesystem path * * @param $uri * @param $file_id * @param mixed $bucket false for uri to be treated as a filesystem path * @return bool */ private function _perform_image_actions($uri, $file_id, $bucket = FALSE) { $this->EE->load->library('filemanager'); $cache_path = 'assets/s3_sources'; $cache_path = Assets_helper::ensure_cache_path($cache_path); if ($bucket) { $target = Assets_helper::get_temp_file(); $this->_s3_set_creds($this->settings()->access_key_id, $this->settings()->secret_access_key); $this->s3->getObject($bucket, $this->_get_path_prefix() . $uri, $target); $uri = $target; } list($width, $height) = getimagesize($uri); $data = array('width' => $width, 'height' => $height); $this->_update_file($data, $file_id); if (strtolower($this->EE->config->item('assets_cache_remote_images')) !== "no") { $target_path = $cache_path . $file_id . '.jpg'; $this->EE->assets_lib->resize_image($uri, $target_path, self::IMAGE_SOURCE_SIZE); } @unlink($uri); }
/** * Perform image actions - resize and save dimensions. If no bucket name provided, $uri is treated as filesystem path * * @param $uri * @param $file_id * @param mixed $download_copy if set to true will download a new copy * @return bool */ private function _perform_image_actions($uri, $file_id, $download_copy = null) { $this->EE->load->library('filemanager'); $cache_path = 'assets/rs_sources'; $cache_path = Assets_helper::ensure_cache_path($cache_path); if ($download_copy) { $target = Assets_helper::get_temp_file(); $this->download_file($uri, $target); $uri = $target; } list($width, $height) = getimagesize($uri); $data = array('width' => $width, 'height' => $height); $this->_update_file($data, $file_id); if (strtolower($this->EE->config->item('assets_cache_remote_images')) !== "no") { $target_path = $cache_path . $file_id . '.jpg'; $this->EE->assets_lib->resize_image($uri, $target_path, self::IMAGE_SOURCE_SIZE); } @unlink($uri); }