protected function getDimensions()
    {
        // Default result
        $result = [0, 0];

        // If we have a resource already loaded, this means we have modified the resource since the
        // original image was loaded. This means the "Variant" tuple key is out of date, and we don't
        // have a reliable cache key to load from, or save to. If we use the original tuple as a key,
        // we would run the risk of overwriting the original dimensions in the cache, with the values
        // of the resized instead.
        // Instead, we use the immediately available dimensions attached to this resource, and we will
        // rely on cache warming in writeToStore to save these values, where the "Variant" becomes available,
        // before the next time this variant is loaded into memory.
        $resource = $this->image;
        if ($resource) {
            return $this->getResourceDimensions($resource);
        }

        // Check if we have a container
        $container = $this->getAssetContainer();
        if (!$container) {
            return $result;
        }

        // Check cache for unloaded image
        $cache = $this->getCache();
        $key = $this->getDimensionCacheKey($container->getHash(), $container->getVariant());
        if ($cache->has($key)) {
            return $cache->get($key);
        }

        // Cache-miss
        $resource = $this->getImageResource();
        if ($resource) {
            $result = $this->getResourceDimensions($resource);
            $cache->set($key, $result);
        }
        return $result;
    }
protected function getDimensions()
    {
        // Default result
        $result = [0, 0];

        // If we have a resource already loaded, this means we have modified the resource since the
        // original image was loaded. This means the "Variant" tuple key is out of date, and we don't
        // have a reliable cache key to load from, or save to. If we use the original tuple as a key,
        // we would run the risk of overwriting the original dimensions in the cache, with the values
        // of the resized instead.
        // Instead, we use the immediately available dimensions attached to this resource, and we will
        // rely on cache warming in writeToStore to save these values, where the "Variant" becomes available,
        // before the next time this variant is loaded into memory.
        $resource = $this->image;
        if ($resource) {
            return $this->getResourceDimensions($resource);
        }

        // Check if we have a container
        $container = $this->getAssetContainer();
        if (!$container) {
            return $result;
        }

        // Check cache for unloaded image
        $cache = $this->getCache();
        $key = $this->getDimensionCacheKey($container->getHash(), $container->getVariant());
        if ($cache->has($key)) {
            return $cache->get($key);
        }

        // Cache-miss
        $resource = $this->getImageResource();
        if ($resource) {
            $result = $this->getResourceDimensions($resource);
            $cache->set($key, $result);
        }
        return $result;
    }
protected function getDimensions ( ) { // Default result $ result = [ 0 , 0 ] ; // If we have a resource already loaded, this means we have modified the resource since the // original image was loaded. This means the "Variant" tuple key is out of date, and we don't // have a reliable cache key to load from, or save to. If we use the original tuple as a key, // we would run the risk of overwriting the original dimensions in the cache, with the values // of the resized instead. // Instead, we use the immediately available dimensions attached to this resource, and we will // rely on cache warming in writeToStore to save these values, where the "Variant" becomes available, // before the next time this variant is loaded into memory. $ resource = $ this -> image ; if ( $ resource ) { return $ this -> getResourceDimensions ( $ resource ) ; } // Check if we have a container $ container = $ this -> getAssetContainer ( ) ; if ( ! $ container ) { return $ result ; } // Check cache for unloaded image $ cache = $ this -> getCache ( ) ; $ key = $ this -> getDimensionCacheKey ( $ container -> getHash ( ) , $ container -> getVariant ( ) ) ; if ( $ cache -> has ( $ key ) ) { return $ cache -> get ( $ key ) ; } // Cache-miss $ resource = $ this -> getImageResource ( ) ; if ( $ resource ) { $ result = $ this -> getResourceDimensions ( $ resource ) ; $ cache -> set ( $ key , $ result ) ; } return $ result ; }
Return dimensions as array with cache enabled

@return array Two-length array with width and height
Return dimensions as array with cache enabled