You have seen in Facebook, that how we give a url and it extract data such as images, title and description. Here now you can get this amazing script at 99Points. You have seen amazing and popular facebook style tutorials which can help you to get some amazing effects on your websites. I have created this awesome tutorial which is 99% same as facebook style. Check the demo and download the source code.
JQuery Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
// <![CDATA[ $(document).ready(function(){ // delete event $('#attach').livequery("click", function(){ if(!isValidURL($('#url').val())) { alert('Please enter a valid url.'); return false; } else { $('#load').show(); $.post("fetch.php?url="+$('#url').val(), { }, function(response){ $('#loader').html($(response).fadeIn('slow')); $('.images img').hide(); $('#load').hide(); $('img#1').fadeIn(); $('#cur_image').val(1); }); } }); // next image $('#next').livequery("click", function(){ var firstimage = $('#cur_image').val(); $('#cur_image').val(1); $('img#'+firstimage).hide(); if(firstimage <= $('#total_images').val()) { firstimage = parseInt(firstimage)+parseInt(1); $('#cur_image').val(firstimage); $('img#'+firstimage).show(); } }); // prev image $('#prev').livequery("click", function(){ var firstimage = $('#cur_image').val(); $('img#'+firstimage).hide(); if(firstimage]]>0) { firstimage = parseInt(firstimage)-parseInt(1); $('#cur_image').val(firstimage); $('img#'+firstimage).show(); } }); // watermark input fields jQuery(function($){ $("#url").Watermark("http://"); }); jQuery(function($){ $("#url").Watermark("watermark","#369"); }); function UseData(){ $.Watermark.HideAll(); $.Watermark.ShowAll(); } }); function isValidURL(url){ var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; if(RegExp.test(url)){ return true; }else{ return false; } } // ]]> |
index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<input id="cur_image" name="cur_image" type="hidden" /> <div class="wrap" align="center"> <div class="box" align="left"> <div class="head">Link</div> <div class="close" align="right"> <div class="closes"> </div> </div> <br clear="all" /><br clear="all" /><input id="url" name="url" size="64" type="text" /> <input id="attach" name="attach" type="button" value="Attach" /> <br clear="all" /> <div id="loader"> <div id="load" style="display: none;" align="center"><img src="load.gif" /></div> </div> </div> </div> |
fetch.php
I have get images and title using fopen method of php but for description I used get_meta_tags() function which returns meta tags of url. After getting all images I just put a loop and get all images which size is greater than 100px so that small images should not be included. I have created this tutorial separate from our facebook style wall posting and comment application and facebook profile edit. However if you want to add this functionality in that script just download all files and add your code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
$url = $_REQUEST['url']; $url = checkValues($url); function checkValues($value) { $value = trim($value); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = strtr($value, array_flip(get_html_translation_table(HTML_ENTITIES))); $value = strip_tags($value); $value = htmlspecialchars($value); return $value; } function fetch_record($path) { $file = fopen($path, "r"); if (!$file) { exit("Problem occured"); } $data = ''; while (!feof($file)) { $data .= fgets($file, 1024); } return $data; } $string = fetch_record($url); /// fecth title $title_regex = "/<title-->(.+)<\/title>/i"; preg_match_all($title_regex, $string, $title, PREG_PATTERN_ORDER); $url_title = $title[1]; /// fecth decription $tags = get_meta_tags($url); // fetch images $image_regex = '/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui'; preg_match_all($image_regex, $string, $img, PREG_PATTERN_ORDER); $images_array = $img[1]; <div class="images"> $k=1; for ($i=0;$i<=sizeof($images_array);$i++) { if(@$images_array[$i]) { if(@getimagesize(@$images_array[$i])) { list($width, $height, $type, $attr) = getimagesize(@$images_array[$i]); if($width -->= 50 && $height >= 50 ){ echo "<img id="".$k."" src="".@$images_array[$i]."" width="100" />"; $k++; } } } } ?> <!--<img src="ajax.jpg" alt="" />--> <input id="total_images" name="total_images" type="hidden" value="<?php echo --$k?>" /></div> <div class="info"><label class="title"> <!--?php echo @$url_title[0]; ?--> </label> <br clear="all" /><label class="url"> <!--?php echo substr($url ,0,35); ?--> </label> <br clear="all" /><br clear="all" /><label class="desc"> <!--?php echo @$tags['description']; ?--> </label> <br clear="all" /><br clear="all" /><label style="float: left;"><img id="prev" src="prev.png" alt="" /><img id="next" src="next.png" alt="" /></label> <label class="totalimg"> Total <!--?php echo $k?--> images </label> </div> |
Download all files and use this awesome tutorial.
Yeah. Images don’t load. Would be nice if they did.
hello Johannes, your script looks good. We are trying to download it from: ‘http://www.screamlabs.at/dev/fetch/fetch.zip’ but this link is not working.
I was wondering if it has been shifted to some other location? Could you please provide us a new link or email us directly at nitinwaves@gmail.com
nice https://uploads.disquscdn.com/images/e748431cf4f3f448fe1db1f45d1890b6c1db8257a4c7c949047d14dad9e8b534.jpg