我們偵測到您正在使用Ad Block插件來阻止廣告顯示

It looks like you're using an ad-blocker!

您好!我們偵測到您正在使用Ad Block插件來阻止廣告顯示,你知道嗎?我們是沒有收取讀者的任何費用,而我們的主要收有入來源是廣告費,所以如果沒有資金維持成本,我們網站是很難經營下去。 請停用這些廣告攔截器來支持我們「灣仔298電腦資訊網」「www.wanchai298.com」,讓我們的廣告可以顯示。謝謝您的理解。

298討論區

WPforo論壇怎樣在帖內直接顯示圖片
 
Notifications
Clear all

WPforo論壇怎樣在帖內直接顯示圖片

1 Posts
1 Users
0 Likes
1,708 Views
0
Topic starter

可以在風格的functions.php檔案中,(風格位置: wp-content/themes/)加入以下代碼:

add_filter('wpforo_content_filter', 'wpforo_default_attachment_image_embed', 11);
function wpforo_default_attachment_image_embed( $content ){
    if( preg_match_all('|<a class=\"wpforo\-default\-attachment\" href\=\"([^\"\']+)\"[^><]*>.+?<\/a>|is', $content, $data, PREG_SET_ORDER) ){
        foreach($data as $array){
            if(isset($array[1])){
                $file = $array[1];
                $e = strtolower(substr(strrchr($file, '.'), 1));
                if( $e == 'jpg' || $e == 'jpeg' || $e == 'png' || $e == 'gif' ){
                    $filename = basename($file);
                    $html = '<a class="wpforo-default-image-attachment" href="' . esc_url($file) . '" target="_blank"><img src="' . esc_url($file) . '" alt="' . esc_attr($filename) . '" title="' . esc_attr($filename) . '" /></a>';
                    $content = str_replace($array[0], $html, $content);
                }
            }
        }
    }
    return $content;
}

詳情亦可以參看官方原文:

http://wpforo.com/community/how-to-and-troubleshooting-2/uploading-and-embedding-images/

1 Answer
0
Topic starter

For embed Youtube video, add this to 風格的functions.php檔案中,(風格位置: wp-content/themes/)加入以下代碼::

 

add_filter('wpforo_content_after', 'wpforo_custom_video_embed', 10);
function wpforo_custom_video_embed( $content ){
$paterns = array();
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$paterns[] = "/<a[^><]+>\s*[a-zA-Z\/\/:\.]*youtu.be\/([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i";
$content = preg_replace($paterns, "<iframe width=\"100%\" height=\"280\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $content);
return $content;
}
This post was modified 4 年 ago by 298站長
Share: