/** * Get the image * @return str: hash name / image size (useful for tests) */ public function getImage() { $sizes = array('small', 'medium', 'large'); if (is_null($this->size) || !in_array($this->size, $sizes)) { $this->size = 'medium'; } $image_download = new HTTP_Download(); $image_download->setContentType('image/jpeg'); $image_download->setBufferSize(8192); $image_download->setCacheControl('public', 86040000); $image_download->setContentDisposition(HTTP_DOWNLOAD_INLINE, $this->size . '.jpg'); //if art exists stream it to the user, otherwise stream the default placeholder graphics if (is_readable($this->art_dir . '/' . $this->hash . '/' . $this->size . '.jpg') === false) { $image_download->setFile($this->art_dir . '/placeholder/' . $this->size . '.jpg'); $this->hash = 'placeholder'; } else { $image_download->setFile($this->art_dir . '/' . $this->hash . '/' . $this->size . '.jpg'); } $this->log(sprintf('Sending Artwork: %s - Size: %s - Filename: %s', $this->hash, $this->size, $this->art_dir . '/' . $this->hash . '/' . $this->size . '.jpg')); $image_download->send(); return $this->hash . '/' . $this->size . '.jpg'; }