Timber\ImageHelper::get_sideloaded_file_loc PHP Method

get_sideloaded_file_loc() public static method

Determines the filepath where a given external file will be stored.
public static get_sideloaded_file_loc ( string $file ) : string
$file string
return string
    public static function get_sideloaded_file_loc($file)
    {
        $upload = wp_upload_dir();
        $dir = $upload['path'];
        $filename = $file;
        $file = parse_url($file);
        $path_parts = pathinfo($file['path']);
        $basename = md5($filename);
        $ext = 'jpg';
        if (isset($path_parts['extension'])) {
            $ext = $path_parts['extension'];
        }
        return $dir . '/' . $basename . '.' . $ext;
    }