javascript - Any Lightbox for Cross-Domain Iframe -
searching alot on topic no solution... :( looking lightbox pictures in cross domain environment
thankx in advance.
i'm not sure you're asking here, if you're looking circumvent cross-domain js restrictions, can create php page (or similar) on server fetches images domain , serves them local.
here jquery code change image object's src
attribute show specific picture. lets want show image http://www.someotherdomain.com/images/pictureofbacon.png
....
var urlstr = 'http://www.someotherdomain.com/images/pictureofbacon.png'; //encode image's url passing var url_enc = encodeuricomponent(urlstr); $('#imagebacon').attr( 'src', 'http://www.yourdomain.com/getphoto?url=' + url_enc ); //call php page, passing encode image url
then, in php page, can url , process image locally. php tested work (requires gd2), assuming pass valid image url.
getphoto.php
<?php $url = $_request['url']; sendimagetobrowser ($url); function sendimagetobrowser($file){ $info = getimagesize($file); $final_width=$info[0]; $final_height=$info[1]; switch ( $info[2] ) { case imagetype_gif: $image = imagecreatefromgif($file); break; case imagetype_jpeg: $image = imagecreatefromjpeg($file); break; case imagetype_png: $image = imagecreatefrompng($file); break; default: return false; } imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old); $mime = image_type_to_mime_type($info[2]); header("content-type: $mime"); $output = null; switch ( $info[2] ) { case imagetype_gif: imagegif($image, $output); break; case imagetype_jpeg: imagejpeg($image, $output); break; case imagetype_png: imagepng($image, $output); break; default: return false; } return true; } ?>
Comments
Post a Comment