Пример #1
0
 /**
  * Helper function: Initialize the WikiaUploadStashFile for a given file.
  *
  * @param $path String: path to file
  * @param $key String: key under which to store the object
  * @throws UploadStashZeroLengthFileException
  * @return bool
  */
 protected function initFile($key)
 {
     $file = new WikiaUploadStashFile($this->repo, $this->fileMetadata[$key]['us_path'], $key);
     if ($file->getSize() === 0) {
         throw new UploadStashZeroLengthFileException("File is zero length");
     }
     $this->files[$key] = $file;
     return true;
 }
 /**
  * Creates stashed image url and returns it
  *
  * @param WikiaUploadStashFile $file
  * @param int $type Image type to return IMAGE_ORIGINAL or IMAGE_THUMBNAIL
  * @param int $width optional width of the thumbnail
  *
  * @return String image url
  *
  * @throws MWException
  */
 public function getStashedImage(WikiaUploadStashFile $file, $type = self::IMAGE_ORIGINAL, $width = 200)
 {
     if ($type === self::IMAGE_ORIGINAL) {
         $url = $file->getOriginalFileUrl();
     } else {
         if ($type === self::IMAGE_THUMBNAIL) {
             $url = $file->getThumbUrl($width . "px-" . $file->getName());
         } else {
             throw new MWException('Invalid $type parameter');
         }
     }
     return wfReplaceImageServer($url);
 }