|
Most hosting companies set allow_url_fopen to false and for good reason. Unfortunately this means directResize will not work in a lot of cases.
Either the full file path would need to be in getimagesize (instead of the url) or we need to use curl. The full path method requires more setup information so I’m not sure if it’s a very good solution.
One method using the curl library is the following:
Replace
public function directResize($img_min_w, $img_min_h, $ratio=0, $autoriseAgrandissement = false)
{
//--> Recherche des dimentions de l’image d’origine
$size = getimagesize($this);
$img_src_w = $size[0];
$img_src_h = $size[1];
With
public function directResize($img_min_w, $img_min_h, $ratio=0, $autoriseAgrandissement = false)
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $this->__toString());
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$file_contents = curl_exec($ch);
curl_close($ch);
if (!is_string($file_contents) || !isset($file_contents[0])) {
return $this->resize($img_min_w, $img_min_h);
}
$image = ImageCreateFromString($file_contents);
$img_src_w = imagesx($image);
$img_src_h = imagesy($image);
|