Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] This script blocks oEmbed


  • LZL0
    Participant

    @lchief

    How can this script block oEmbed?
    It is an auto-embed image script. It gets the url of the image and converts it into an image.
    `function content_magic($content) {

    $content = get_the_content();

    $m= preg_match_all(‘!http://[a-z0-9\-\.\/]+\.(?:jpeg|jpg|png|gif)!Ui’ , $content , $matches);

    if ($m) {
    $links=$matches[0];
    for ($j=0;$j<$m;$j++) {
    $content=str_replace($links[$j],'‘,$content);
    }
    }

    return $content;
    }
    add_filter(‘the_content’,’content_magic’);`

    How can I solve this Problem?
    Thank you in advance,
    Chief

Viewing 10 replies - 1 through 10 (of 10 total)

  • LZL0
    Participant

    @lchief

    sorry this is the exact code:

    function content_magic($content) {

    $content = get_the_content();

    $m= preg_match_all(‘!http://a-z0-9\-\.\/]+\.(?:jpeg|jpg|png|gif)!Ui’ , $content , $matches);

    if ($m) {
    $links=$matches[0];
    for ($j=0;$j<$m;$j++) {
    $content=str_replace($links[$j],''‘,$content);
    }
    }

    return $content;
    }
    add_filter(‘the_content’,’content_magic’);


    meg@info
    Participant

    @megainfo

    Hi,

    Add this code yo your functions.php, i was add filter to embed_maybe_make_link wp function.

    It work!! but mybe there is more good solution for auto-embeding image in bp (personaly, i was search since for long time for solution, but i dont find it :p).

    `
    /**
    * Check if url is image
    * @param [type] $url
    * @return boolean
    */
    function isImage( $url ){
    $pos = strrpos( $url, “.”);
    if ($pos === false)
    return false;
    $ext = strtolower(trim(substr( $url, $pos)));
    $imgExts = array(“.gif”, “.jpg”, “.jpeg”, “.png”, “.tiff”, “.tif”); // this is far from complete but that’s always going to be the case…
    if ( in_array($ext, $imgExts) )
    return true;
    return false;
    }

    function embed_maybe_make_image($output, $url) {
    // this comented code check if is image by using getimagesize function, it use curl to check
    // if is image or no, it little slow than isImage function
    //if( getimagesize($url) != false ){
    if(isImage($url)){
    return ‘‘;
    }
    }
    add_filter( ’embed_maybe_make_link’, ’embed_maybe_make_image’, 10, 2 );
    `


    LZL0
    Participant

    @lchief

    Thank you very very much! 😀


    meg@info
    Participant

    @megainfo

    U Welcome 😛


    funmi omoba
    Participant

    @funmi-omoba

    hi @lchief, @megainfo,

    Thanks for sharing this script, please is there a way to specify the height and width of the images.

    Regards


    meg@info
    Participant

    @megainfo

    Hi

    just edit this line
    `return ‘‘;`

    to

    `return ‘‘;`

    The proper way is by using css class.


    funmi omoba
    Participant

    @funmi-omoba

    @megainfo,

    Bravo, work like a charm


    funmi omoba
    Participant

    @funmi-omoba

    @megainfo, unfortunately this script makes activity un editable from WP-admin backend


    meg@info
    Participant

    @megainfo

    You can edit the activity,

    but at the place of the link of the image, you will get html code of image.


    LZL0
    Participant

    @lchief

    if(! is_admin()) {
    Script
    }

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] This script blocks oEmbed’ is closed to new replies.
Skip to toolbar