Created
May 24, 2014 01:05
-
-
Save bytefade/63d390a7f49e7ac3841f to your computer and use it in GitHub Desktop.
Alternativa para getimagesize em ambientes windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ranger($url){ | |
$headers = array( | |
"Range: bytes=0-32768" | |
); | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
$data = curl_exec($curl); | |
curl_close($curl); | |
return $data; | |
} | |
function get_id_thumb_url($thumb_id, $size, $key) | |
{ | |
$thumb_url = wp_get_attachment_image_src($thumb_id,$size, false); | |
//post_excerpt - legenda | |
$legenda = retorna_caption($thumb_id); | |
$url = $thumb_url[0]; | |
$raw = ranger($url); | |
$im = imagecreatefromstring($raw); | |
$width = imagesx($im); | |
$height = imagesy($im); | |
if ($height<400) { $classImg = 'img-min'; $id='id="frontal-img"'; }else{ $classImg = 'img-500'; } | |
echo ' | |
<div class="pure-u-1-5 filho-pure" style="padding-right: 6px;" '.$id.'> | |
<img class="pure-img-responsive '.$classImg.'" src="' .$thumb_url[0]. '" alt="'.$legenda.'"> | |
<!-- legenda --> | |
<div class="pure-u-1 post-image-meta-bg"> | |
<div class="post-image-meta"> | |
<h3>'.$legenda.'</h3> | |
</div> | |
</div> | |
</div> | |
'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment