Gets medium image, resets image manipulation operations.

@return $this
166612
protected function image()
    {
        $locator = Grav::instance()['locator'];

        $file = $this->get('filepath');

        // Use existing cache folder or if it doesn't exist, create it.
        $cacheDir = $locator->findResource('cache://images', true) ?: $locator->findResource('cache://images', true, true);

        // Make sure we free previous image.
        unset($this->image);

        $this->image = ImageFile::open($file)
            ->setCacheDir($cacheDir)
            ->setActualCacheDir($cacheDir)
            ->setPrettyName($this->getImagePrettyName());

        return $this;
    }
827964
public function getImageResized()
    {
        if ($this->Image()->exists()) {
            $image = $this->Image();
        } elseif ($this->LinkPage()->hasMetaImage()) {
            $image = $this->LinkPage()->getMetaImage();
        }
        
        return $this->performImageResize($image);
    }
38476
private function getImage()
    {
        $image = $this->_parser->find('.container-left .user-profile', 0);
        $image = $image->find('.user-image img', 0);

        return $image ? Helper::imageUrlCleaner($image->src) : '';
    }
1325568
public function getCoverImage()
    {
        if ($this->getBlock() === null) {
            return false;
        }

        foreach ($this->getBlock()->getOwning() as $block) {
            $reflect = new \ReflectionClass($block);

            if ($reflect->hasProperty('media') && $block->getMedia()) {
                return $block->getMedia()->getReference();
            }
        }

        return false;
    }
1172822
public function getImageDimensions()
    {
        $dimension = $this->getData()->chained->getComponent()->_getSetting('dimension');
        if ($this->getData()->chained->getComponent()->getRow()->use_crop) {
            $parentDimensions = $this->_getImageEnlargeComponent()->getImageDimensions();
            $dimension['crop'] = $parentDimensions['crop'];
        }
        $data = $this->getImageData();
        return Kwf_Media_Image::calculateScaleDimensions($data['file'], $dimension);
    }
1170600
public function getMedia()
    {
        // if media was set by setMedia() use this->media
        if ($this->media) {
            return $this->media;
        }
        $mediaCollection = [];
        $media = $this->entity->getMedia();
        if (!$media) {
            return $mediaCollection;
        }
        foreach ($media as $medium) {
            $mediaCollection[] = new Media($medium, $this->locale);
        }

        return $mediaCollection;
    }
1149651
public function getAsImage()
    {
        if ($this->asImage === null) {
            $this->asImage = $this->getGenerator()->generateImage($this);;
        }
        return $this->asImage;
    }
584563
public function thumbnail()
    {
        if (is_null($thumbnailURL = $this->entity->getImagePath()))
        {
            return $this->iconThumbnail('document');
        }

        return $this->wrapThumbnail(
            $this->filteredImageWith('rthumb', 'document-thumbnail__image')
        );
    }
622193
public function getImageResource()
    {
        // Get existing resource
        if ($this->image) {
            return $this->image;
        }

        // Load container
        $assetContainer = $this->getAssetContainer();
        if (!$assetContainer) {
            return null;
        }

        // Avoid repeat load of broken images
        $hash = $assetContainer->getHash();
        $variant = $assetContainer->getVariant();
        if ($this->hasFailed($hash, $variant)) {
            return null;
        }

        // Validate stream is readable
        // Note: Mark failed regardless of whether a failed stream is exceptional or not
        $error = self::FAILED_MISSING;
        try {
            $stream = $assetContainer->getStream();
            if ($this->isStreamReadable($stream)) {
                $error = null;
            } else {
                return null;
            }
        } finally {
            if ($error) {
                $this->markFailed($hash, $variant, $error);
            }
        }

        // Handle resource
        $error = self::FAILED_UNKNOWN;
        try {
            // write the file to a local path so we can extract exif data if it exists.
            // Currently exif data can only be read from file paths and not streams
            $path = tempnam(TEMP_PATH, 'interventionimage_');
            if ($extension = pathinfo($assetContainer->getFilename(), PATHINFO_EXTENSION)) {
                //tmpnam creates a file, we should clean it up if we are changing the path name
                unlink($path);
                $path .= "." . $extension;
            }
            $bytesWritten = file_put_contents($path, $stream);
            // if we fail to write, then load from stream
            if ($bytesWritten === false) {
                $resource = $this->getImageManager()->make($stream);
            } else {
                $this->setTempPath($path);
                $resource = $this->getImageManager()->make($path);
            }

            // Fix image orientation
            try {
                $resource->orientate();
            } catch (NotSupportedException $e) {
                // noop - we can't orientate, don't worry about it
            }

            $this->setImageResource($resource);
            $this->markSuccess($hash, $variant);
            $this->warmCache($hash, $variant);
            $error = null;
            return $resource;
        } catch (NotReadableException $ex) {
            // Handle unsupported image encoding on load (will be marked as failed)
            // Unsupported exceptions are handled without being raised as exceptions
            $error = self::FAILED_INVALID;
        } finally {
            if ($error) {
                $this->markFailed($hash, $variant, $error);
            }
        }
        return null;
    }
830339
protected function initSourceImageResource() 
    { 
    	$ext = $this->getExtension();
    	
    	switch($ext) {
		case 'gif':
			$this->sourceImageResource = ImageCreateFromGif($this->sourceImagePath);
			break;
    	
		case 'jpg':
			$this->sourceImageResource = ImageCreateFromJpeg($this->sourceImagePath);
			break;
    	
		case 'png':
			$this->sourceImageResource = ImageCreateFromPng($this->sourceImagePath);
			break;
    	
		default:
			throw new \RuntimeException("An error occurred trying to create the image, extension '" . $ext. "' is not supported");
			break;
    	}
    	
    	return $this;
    }
909101
public function getImageUrlAttribute()
    {
        if ($this->exists) {
            $image = $this->image();

            if ($image) {
                return $image->url;
            }

            return config('media.image.default');
        }

        return config('media.image.default');
    }
507257
public function GetPrimaryImage()
    {
        $oPrimaryImage = &$this->GetFromInternalCache('oPrimaryImage');
        if (is_null($oPrimaryImage)) {
            if (!empty($this->fieldCmsMediaDefaultPreviewImageId) && (!is_numeric($this->fieldCmsMediaDefaultPreviewImageId) || intval($this->fieldCmsMediaDefaultPreviewImageId) > 1000)) {
                $oShop = TdbShop::GetInstance();
                $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $this->fieldCmsMediaDefaultPreviewImageId, 'position' => 1);
                $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                $oPrimaryImage->LoadFromRow($aData);
            } else {
                $oImages = &$this->GetFieldShopArticleImageList();
                $activePage = $this->getActivePageService()->getActivePage();
                if (0 == $oImages->Length() && (!is_null($activePage))) {
                    $oShop = TdbShop::GetInstance();
                    $aData = array('shop_article_id' => $this->id, 'cms_media_id' => $oShop->fieldNotFoundImage, 'position' => 1);
                    $oPrimaryImage = TdbShopArticleImage::GetNewInstance();
                    $oPrimaryImage->LoadFromRow($aData);
                } else {
                    $oImages->GoToStart();
                    $oPrimaryImage = &$oImages->Current();
                }
            }

            if (false === $oPrimaryImage) {
                $oPrimaryImage = null;
                if ($this->IsVariant()) {
                    $oParent = $this->GetFieldVariantParent();
                    if (null != $oParent) {
                        $oPrimaryImage = $oParent->GetPrimaryImage();
                    }
                }
            }
            $this->SetInternalCache('oPrimaryImage', $oPrimaryImage);
        }

        return $oPrimaryImage;
    }
1268166
public function image()
    {
        if ($this->relationLoaded('mediables')) {
            return $this->mediables->where('type', 'image')->first();
        }

        return $this->mediables()
            ->where('media.type', 'image')
            ->whereNull('mediables.type')
            ->first();
    }
371660
protected function getMedia() {
        if (!$this->_media) {
            $this->_media = new MediaList(
                $this->version,
                $this->solution['accountSid'],
                $this->solution['sid']
            );
        }

        return $this->_media;
    }
309322
public function getMedia()
    {
        if ($this->media === null) {
            $cache = $this->getMediaCache();

            // Use cached media if possible.
            $cacheKey = md5('media' . $this->getCacheKey());
            if (!$media = $cache->get($cacheKey)) {
                $media = new Media($this->getMediaFolder(), $this->getMediaOrder());
                $cache->set($cacheKey, $media);
            }
            $this->media = $media;
        }

        return $this->media;
    }
119907
public function getAvatarImage(): ?ImageMedium
    {
        $avatars = $this->get('avatar');
        if (\is_array($avatars) && $avatars) {
            $avatar = array_shift($avatars);

            $media = $this->getMedia();
            $name = $avatar['name'] ?? null;

            $image = $name ? $media[$name] : null;
            if ($image instanceof ImageMedium) {
                return $image;
            }
        }

        return null;
    }
610151
public function getSlideImage()
    {
        if ($this->hasImage()) {
            
            if ($this->Image()->exists()) {
                return $this->Image();
            } elseif ($this->LinkPage()->hasMetaImage()) {
                return $this->LinkPage()->getMetaImage();
            }
            
        }
    }