When action on a single grouping, returns the image of himself

@return \record_adapter
422756
public function get_grouping_head()
    {
        if (!$this->is_single_grouping())
            throw new \Exception('Cannot use ' . __METHOD__ . ' here');
        foreach ($this->get_elements() as $record) {
            return $record;
        }
    }
1370919
public function Resampled()
    {
        // If image is already resampled, return self reference
        $variant = $this->getVariant();
        if ($variant) {
            return $this;
        }

        // Resample, but fallback to original object
        $result = $this->manipulateImage(__FUNCTION__, function (Image_Backend $backend) {
            return $backend;
        });
        if ($result) {
            return $result;
        }
        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;
    }
1353804
protected function getActionRenderer()
    {
        $obj = null;
        if ($this instanceof FormSidebarInterface) {
            if ($this->form()) {
                $obj = $this->form()->obj();
            }
        }

        if ($this instanceof ObjectContainerInterface) {
            $obj = $this->obj();
        }

        if ($this instanceof CollectionContainerInterface) {
            $obj = isset($this->currentObj) ? $this->currentObj : $this->proto();
        }

        return $obj instanceof ViewableInterface ? $obj : null;
    }
317586
public function opengraphImage()
    {
        $context = $this->contextObject();

        $img = null;
        if ($context instanceof HasOpenGraphInterface) {
            $img = (string)$context['opengraph_image'];
        }

        if (!$img) {
            $img = (string)$this->fallbackOpengraphImage();
        }

        if ($img) {
            $uri = $this->baseUrl();
            return $uri->withPath(strval($img));
        }

        return $this->metaImage();
    }
295698
private function getAdvancedUploadedImage()
    {
        if (! isset($this->advancedUplodedImage)) {
            $this->advancedUplodedImage = $this->makeAdvancedUploadedImage();
        }

        return $this->advancedUplodedImage;
    }
214930
public function getPhoto() {
		if(is_null($photo = $this->tag->getChild('PHOTO'))) {
			return NULL;
		} else {
			try {
				return new Avatar($photo);
			} catch(Exception $e) {
				return NULL;
			}
		}
	}
866012
protected function getAllImages()
    {
        $table = ORM::getTable($this->getTable()->getPlugin(), 'Image');
        $q = $table->createSelectQuery();
        $q->where($q->expr->eq('groupId', $q->bindValue($this->id, null, PDO::PARAM_INT)));
        $q->orderBy('position');
        return $table->loadFromQuery($q);
    }
981277
public function viewAction()
	{
		$node = $this->getFile();

		$nodeOutput = $this->imageAndFileOutput($node);
		$output = array($nodeOutput);

		$return = array(
			'totalRecords' => count($output),
			'records' => $output,
		);

		return new SupraJsonResponse($return);
	}
1021008
protected function getImageUrlOrDefault()
    {
        $imagePath = $this->entity->path;

        if (!Storage::exists($imagePath)) {
            $imagePath = $this->imgNotFound();
        }

        return Storage::url($imagePath);
    }
784088
public function image()
    {
        if (!\count($this)) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        $node = $this->getNode(0);

        if (!$node instanceof \DOMElement) {
            throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
        }

        return new Image($node, $this->baseHref);
    }
885876
public function getProfilePictureAction()
    {
        $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
        $moduleSvc = $this->getServiceLocator()->get('ModulesService');
        $user = $melisCoreAuth->getIdentity();
        $imageDefault = $moduleSvc->getModulePath('MelisCore') . '/public/images/profile/default_picture.jpg';

        if (!empty($user) && !empty($user->usr_image)) {
            $image = $user->usr_image;
        } else {
            $image = file_get_contents($imageDefault);
        }

        $response = $this->getResponse();

        $response->setContent($image);
        $response->getHeaders()
            ->addHeaderLine('Content-Transfer-Encoding', 'binary')
            ->addHeaderLine('Content-Type', 'image/jpg');

        return $response;
    }
1284658
public function getImagine()
    {
        if (!$this->imagine) {
            $this->imagine = $this->getServiceLocator()->get('HtImg\Imagine');
        }

        return $this->imagine;
    }
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;
    }
1051790
public function getAvatar()
    {
        $avatarUrl = null;
        $avatarWidth = 0;

        // find the biggest image
        if (!empty($this->response['pictures']['sizes']) && is_array($this->response['pictures']['sizes'])) {
            foreach ($this->response['pictures']['sizes'] as $picture) {
                if ($picture['width'] > $avatarWidth) {
                    $avatarUrl = $picture['link'];
                    $avatarWidth = $picture['width'];
                }
            }
        }

        return $avatarUrl;
    }
1149651
public function getAsImage()
    {
        if ($this->asImage === null) {
            $this->asImage = $this->getGenerator()->generateImage($this);;
        }
        return $this->asImage;
    }
249258
public function getThumbAttribute()
    {
        if (!$this->isImage)
            return null;

        $thumb_style = ImageStyle::where('name', 'Chronos Thumbnail')->first()->id;
        $thumb = $this->image_styles()->where('image_style_id', $thumb_style)->first();

        if ($thumb)
            return $thumb->file;
        else
            return $this->file;
    }