code/dataobjects/CdnImage.php
public function getDimensions($dim = "string") {
        if(!$this->getField('Filename')) {
            return null;
        }

        $imageDimensions = $this->getDimensionsFromDB($dim);
        if ($imageDimensions !== null) {
            return $imageDimensions;
        }

        // Download file from S3/CDN if we do not have dimensions stored in the DB
        $pointer = $this->obj('CDNFile');
        if($this->ID && $pointer->exists()) {
            $this->ensureLocalFile();
        }

        if (!$this->localFileExists()) {
            return null;
        }

        // Store in 'ImageDim' field and write if they've changed.
        $this->storeDimensions();
        if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
            $this->write();
        }
        // Load dimensions
        return $this->getDimensionsFromDB($dim);
    }
public function getDimensions($dim = "string") {
        if(!$this->getField('Filename')) {
            return null;
        }

        $imageDimensions = $this->getDimensionsFromDB($dim);
        if ($imageDimensions !== null) {
            return $imageDimensions;
        }

        // Download file from S3/CDN if we do not have dimensions stored in the DB
        $pointer = $this->obj('CDNFile');
        if($this->ID && $pointer->exists()) {
            $this->ensureLocalFile();
        }

        if (!$this->localFileExists()) {
            return null;
        }

        // Store in 'ImageDim' field and write if they've changed.
        $this->storeDimensions();
        if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
            $this->write();
        }
        // Load dimensions
        return $this->getDimensionsFromDB($dim);
    }
public function getDimensions ( $ dim = "string" ) { if ( ! $ this -> getField ( 'Filename' ) ) { return null ; } $ imageDimensions = $ this -> getDimensionsFromDB ( $ dim ) ; if ( $ imageDimensions !== null ) { return $ imageDimensions ; } // Download file from S3/CDN if we do not have dimensions stored in the DB $ pointer = $ this -> obj ( 'CDNFile' ) ; if ( $ this -> ID && $ pointer -> exists ( ) ) { $ this -> ensureLocalFile ( ) ; } if ( ! $ this -> localFileExists ( ) ) { return null ; } // Store in 'ImageDim' field and write if they've changed. $ this -> storeDimensions ( ) ; if ( $ this -> isChanged ( 'ImageDim' , \ DataObject :: CHANGE_VALUE ) ) { $ this -> write ( ) ; } // Load dimensions return $ this -> getDimensionsFromDB ( $ dim ) ; }
Captures the image dimensions in a db field to avoid needing to download the file all the time

@param type $dim
@return int|string
Captures the image dimensions in a db field to avoid needing to download the file all the time