src/includes/classes/Core/Utils/Image.php
public function decodeDataUrl(string $url): array
    {
        if (mb_stripos($url, 'data:') !== 0) {
            return []; // Not applicable.
        }
        $data     = str_replace(' ', '+', $url);
        $data_100 = mb_substr($data, 0, 100);

        if (mb_stripos($data_100, 'data:image/x-icon;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/icon;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/ico;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/gif;base64,') === 0) {
            $extension = 'gif';
            //
        } elseif (mb_stripos($data_100, 'data:image/jpg;base64,') === 0) {
            $extension = 'jpg';
            //
        } elseif (mb_stripos($data_100, 'data:image/jpeg;base64,') === 0) {
            $extension = 'jpg';
            //
        } elseif (mb_stripos($data_100, 'data:image/png;base64,') === 0) {
            $extension = 'png';
            //
        } elseif (mb_stripos($data_100, 'data:image/svg+xml;base64,') === 0) {
            $extension = 'svg';
            //
        } elseif (mb_stripos($data_100, 'data:image/webp;base64,') === 0) {
            $extension = 'webp';
        }
        if (empty($extension)) {
            return []; // Not possible.
            //
        } elseif (!($raw_image_data = mb_substr($data, mb_strpos($data, ',') + 1))) {
            return []; // Decode failure.
            //
        } elseif (!($raw_image_data = base64_decode($raw_image_data, true))) {
            return []; // Decode failure.
        }
        return compact('raw_image_data', 'extension');
    }
public function decodeDataUrl(string $url): array
    {
        if (mb_stripos($url, 'data:') !== 0) {
            return []; // Not applicable.
        }
        $data     = str_replace(' ', '+', $url);
        $data_100 = mb_substr($data, 0, 100);

        if (mb_stripos($data_100, 'data:image/x-icon;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/icon;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/ico;base64,') === 0) {
            $extension = 'ico';
            //
        } elseif (mb_stripos($data_100, 'data:image/gif;base64,') === 0) {
            $extension = 'gif';
            //
        } elseif (mb_stripos($data_100, 'data:image/jpg;base64,') === 0) {
            $extension = 'jpg';
            //
        } elseif (mb_stripos($data_100, 'data:image/jpeg;base64,') === 0) {
            $extension = 'jpg';
            //
        } elseif (mb_stripos($data_100, 'data:image/png;base64,') === 0) {
            $extension = 'png';
            //
        } elseif (mb_stripos($data_100, 'data:image/svg+xml;base64,') === 0) {
            $extension = 'svg';
            //
        } elseif (mb_stripos($data_100, 'data:image/webp;base64,') === 0) {
            $extension = 'webp';
        }
        if (empty($extension)) {
            return []; // Not possible.
            //
        } elseif (!($raw_image_data = mb_substr($data, mb_strpos($data, ',') + 1))) {
            return []; // Decode failure.
            //
        } elseif (!($raw_image_data = base64_decode($raw_image_data, true))) {
            return []; // Decode failure.
        }
        return compact('raw_image_data', 'extension');
    }
Decode image data URL.

@since 161011 Initial release.

@param string $url Data URL.

@return array `[raw_image_data, extension]`.