src/Models/CmsModel.php
protected function getImagesWithResizes()
    {
        // first get the images through the relation
        $relation = $this->getRelationForImagesWithResizesCaller();

        $images = $this->{$relation}()->get();

        if (empty($images)) return $images;

        // then get extra info and retrieve the resizes for it
        $fieldId = $this->getCmsReferenceFieldId($relation);

        $resizes = $this->getResizesForFieldId($fieldId);

        if (empty($resizes)) return $images;

        // decorate the images with resizes
        foreach ($images as $image) {

            $fileName = $image->file;
            $imageResizes = [];

            foreach ($resizes as $resize) {

                $imageResizes[ $resize->prefix ] = [
                    'id'     => $resize->id,
                    'prefix' => $resize->prefix,
                    'file'   => $resize->prefix . $fileName,
                    'url'    => Paths::images($resize->prefix . $fileName),
                    'width'  => $resize->width,
                    'height' => $resize->height,
                ];
            }

            // append full resizes info
            $image->resizes = $imageResizes;
        }

        return $images;
    }
protected function getImagesWithResizes()
    {
        // first get the images through the relation
        $relation = $this->getRelationForImagesWithResizesCaller();

        $images = $this->{$relation}()->get();

        if (empty($images)) return $images;

        // then get extra info and retrieve the resizes for it
        $fieldId = $this->getCmsReferenceFieldId($relation);

        $resizes = $this->getResizesForFieldId($fieldId);

        if (empty($resizes)) return $images;

        // decorate the images with resizes
        foreach ($images as $image) {

            $fileName = $image->file;
            $imageResizes = [];

            foreach ($resizes as $resize) {

                $imageResizes[ $resize->prefix ] = [
                    'id'     => $resize->id,
                    'prefix' => $resize->prefix,
                    'file'   => $resize->prefix . $fileName,
                    'url'    => Paths::images($resize->prefix . $fileName),
                    'width'  => $resize->width,
                    'height' => $resize->height,
                ];
            }

            // append full resizes info
            $image->resizes = $imageResizes;
        }

        return $images;
    }
protected function getImagesWithResizes ( ) { // first get the images through the relation $ relation = $ this -> getRelationForImagesWithResizesCaller ( ) ; $ images = $ this -> { $ relation } ( ) -> get ( ) ; if ( empty ( $ images ) ) return $ images ; // then get extra info and retrieve the resizes for it $ fieldId = $ this -> getCmsReferenceFieldId ( $ relation ) ; $ resizes = $ this -> getResizesForFieldId ( $ fieldId ) ; if ( empty ( $ resizes ) ) return $ images ; // decorate the images with resizes foreach ( $ images as $ image ) { $ fileName = $ image -> file ; $ imageResizes = [ ] ; foreach ( $ resizes as $ resize ) { $ imageResizes [ $ resize -> prefix ] = [ 'id' => $ resize -> id , 'prefix' => $ resize -> prefix , 'file' => $ resize -> prefix . $ fileName , 'url' => Paths :: images ( $ resize -> prefix . $ fileName ) , 'width' => $ resize -> width , 'height' => $ resize -> height , ] ; } // append full resizes info $ image -> resizes = $ imageResizes ; } return $ images ; }
Returns resize-enriched images for a special CMS model image relation

To be called from an accessor, so it can return images based on its name,
which should be get<relationname>Attribute().

@return Collection
Returns resize - enriched images for a special CMS model image relation