Goose\Images\ImageUtils::storeImagesToLocalFile PHP 메소드

storeImagesToLocalFile() 공개 정적인 메소드

Writes an image src http string to disk as a temporary file and returns the LocallyStoredImage object that has the info you should need on the image
public static storeImagesToLocalFile ( string[] $imageSrcs, boolean $returnAll, Configuration $config ) : Goose\Images\LocallyStoredImage[]
$imageSrcs string[]
$returnAll boolean
$config Goose\Configuration
리턴 Goose\Images\LocallyStoredImage[]
    public static function storeImagesToLocalFile($imageSrcs, $returnAll, Configuration $config)
    {
        $localImages = self::handleEntity($imageSrcs, $returnAll, $config);
        if (empty($localImages)) {
            return [];
        }
        $locallyStoredImages = [];
        foreach ($localImages as $localImage) {
            $imageDetails = self::getImageDimensions($localImage->file);
            $locallyStoredImages[] = new LocallyStoredImage(['imgSrc' => $localImage->url, 'localFileName' => $localImage->file, 'bytes' => filesize($localImage->file), 'height' => $imageDetails->height, 'width' => $imageDetails->width, 'fileExtension' => self::getFileExtensionName($imageDetails)]);
        }
        return $locallyStoredImages;
    }

Usage Example

예제 #1
0
 /**
  * @param string[] $imageSrcs
  * @param bool $returnAll
  *
  * @return LocallyStoredImage[]
  */
 private function getLocallyStoredImages($imageSrcs, $returnAll = false)
 {
     return ImageUtils::storeImagesToLocalFile($imageSrcs, $returnAll, $this->config());
 }