[Resolved] This script blocks oEmbed
-
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
-
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’);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 );
`Thank you very very much! 😀
U Welcome 😛
Hi
just edit this line
`return ‘‘;`to
`return ‘‘;`
The proper way is by using css class.
Bravo, work like a charm
@megainfo, unfortunately this script makes activity un editable from WP-admin backend
You can edit the activity,
but at the place of the link of the image, you will get html code of image.
if(! is_admin()) {
Script
}
- The topic ‘[Resolved] This script blocks oEmbed’ is closed to new replies.