• Resolved webdevchef

    (@webdevchef)


    Hi,

    Is it possible to check for retina version of image in PHP?

    I came up with something like this

    function checkForRetinaVersion($url){
        $url_retina = str_lreplace(".", "@2x.", $url);
        $ch = curl_init($url_retina);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_exec($ch);
        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
        if($code == 200){
           return $url_retina;
        }else{
           return $url;
        }
        curl_close($ch);
    }

    But this would lead to lot of requests. Any better approach for that?

    Thank you,

    Philip

    https://wordpress.org/plugins/wp-retina-2x/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Check for retina version in PHP’ is closed to new replies.