src/includes/classes/Core/Utils/FileSize.php
public function remoteBytes(string $url, bool $report_failure = false, int $expires_after = 86400): int
    {
        if (!$url) { // If no URL, no file size.
            return $report_failure ? -1 : 0;
        }
        if (($bytes = $this->c::dirCacheGet(__METHOD__, $url)) !== null) {
            return $bytes; // Cached this already.
        } // Get from an existing cache if at all possible.

        $r = $this->c::remoteResponse('HEAD::'.$url, [
            'max_con_secs' => 5, 'max_stream_secs' => 5,
        ]);
        if ($r->code === 200 && isset($r->headers['content-length'])) {
            $bytes = (int) $r->headers['content-length'];
        } else {
            $bytes = $report_failure ? -1 : 0; // Not possible.
        }
        $this->c::dirCacheSet(__METHOD__, $url, $bytes, $expires_after);
        return $bytes; // Cached for future reference.
    }
public function remoteBytes(string $url, bool $report_failure = false, int $expires_after = 86400): int
    {
        if (!$url) { // If no URL, no file size.
            return $report_failure ? -1 : 0;
        }
        if (($bytes = $this->c::dirCacheGet(__METHOD__, $url)) !== null) {
            return $bytes; // Cached this already.
        } // Get from an existing cache if at all possible.

        $r = $this->c::remoteResponse('HEAD::'.$url, [
            'max_con_secs' => 5, 'max_stream_secs' => 5,
        ]);
        if ($r->code === 200 && isset($r->headers['content-length'])) {
            $bytes = (int) $r->headers['content-length'];
        } else {
            $bytes = $report_failure ? -1 : 0; // Not possible.
        }
        $this->c::dirCacheSet(__METHOD__, $url, $bytes, $expires_after);
        return $bytes; // Cached for future reference.
    }
Determines remote file size.

@since 170824.30708 Remote file size.

@param string $url            URL to check size of.
@param int    $expires_after  Cache expires after (in seconds).
@param bool   $report_failure If true, return `-1` on failure.

@return int Remote file size, in bytes.
@note If `$report_failure` is true, `-1` indicates failure.
For example, if file does not exist, or it has no `content-length` header.