Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Facebook-Like Link Preview right in your hand.
PHP JavaScript Perl CSS Erlang
branch: master

Facebook-Like Link Preview

Build Status

Developed by @LeonardoCardoso.

Follow @lc_link_preview on Twitter to get updates of what sites the people are successfully previewing around the globe.

How this works

The algorithm keeps tracking what you are typing in the status field and through regular expressions identifies a url. Thereafter, the text is in the field is passed to PHP that does all the work to analyze all the source code of the url found. If you enter more than one url, it will consider that the first one is the more relevant and it will create a preview. Once the source code of the url is obtained, regular expressions begin to seek out and capture relevant informations on it. These informations is basically the title page, the images contained therein, and a brief description of the content covered in the page.

For mode details, visit

Link Preview

HTTP Server

  • Apache (must support mod_php)

How to added to your project

1 • Scripts

    <script src=''></script>

    <script src='js/linkPreview.js' ></script>

        If you are saving and fetching results from database using FLP,
        you can customize the layout on this script
    <script src='js/linkPreviewRetrieve.js' ></script>

2 • Stylesheets

        This stylesheet is provides the layout of Facebook's former textarea. 
        You can totally customize this!
    <link rel="stylesheet" type="text/css" href="css/linkPreview.css" />

3 • Configuration

Just create your own textarea (or multiple textareas) and bind it to jQuery like this:

        $(document).ready(function() {

            // changing placeholder
            $('#lp2').linkPreview({placeholder: "Second Field"});

            // bind to a tag the results brought from database

4 • Database

To custom your database configurations, you just need to change the following values in php/classes/Database.php

    $host = "localhost";
    $user = "";
    $password = "";
    $database = "linkpreview";

Make sure your columns are the same as those ones in linkpreview.sql.

Result Format

       "url":"original url",
       "pageUrl":"page url",
       "canonicalUrl":"cannonical url",
       "images": "img1|img2|...",
       "videoIframe":"video iframe if it is video"


option default value possible values function
imageQuantity -1 any integer set the max amount of images to be brought (-1 for illimited)
placeholder What's in your mind any string set the placeholder of textarea


Make sure the library php5-curl is installed and enabled on the server, either locally or remotely.

  • Linux
$ sudo apt-get install php5-curl
$ sudo service apache2 restart
$ sudo port install php5-curl 
$ sudo apachectl restart


Twitter: @TheLeoCardz



Copyright (c) 2014 Leonardo Cardoso (
Dual licensed under the MIT (
and GPL ( licenses.
Something went wrong with that request. Please try again.