Xpressengine\Media\MediaManager::is PHP Method

is() public method

파일이 미디어 파일인지 확인
public is ( File $file ) : boolean
$file Xpressengine\Storage\File file instance
return boolean
    public function is(File $file)
    {
        foreach ($this->handlers as $type => $handler) {
            if ($handler->isAvailable($file->mime) === true) {
                return true;
            }
        }
        return false;
    }

Usage Example

 /**
  * Get files of target used
  *
  * @param string $targetId target identifier
  * @return File[]
  */
 public function getFiles($targetId)
 {
     $data = [];
     $fileClass = $this->storage->getModel();
     $files = $fileClass::getByFileable($targetId);
     foreach ($files as $file) {
         $thumbnails = null;
         if ($this->mediaManager->is($file)) {
             $imgClass = $this->mediaManager->getHandler(Media::TYPE_IMAGE)->getModel();
             $thumbnails = $imgClass::getThumbnails($this->mediaManager->make($file), static::THUMBNAIL_TYPE);
         }
         $file->setRelation('thumbnails', $thumbnails);
         $data[] = $file;
     }
     return $data;
 }
All Usage Examples Of Xpressengine\Media\MediaManager::is