全球主机交流论坛

标题: 怎样才能让wordpress的日志缩略图地址是外链? [打印本页]

作者: 604542720    时间: 2015-12-24 16:19
标题: 怎样才能让wordpress的日志缩略图地址是外链?
如题。想让日志的缩略图地址是我指定的图床外链地址。
作者: phpsky    时间: 2015-12-24 16:57
if ( function_exists('add_theme_support') )
add_theme_support('post-thumbnails');
function catch_first_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_img = $matches [1] [0];
  if(empty($first_img)){
                $random = mt_rand(1, 20);
                echo get_bloginfo ( 'stylesheet_directory' );
                echo '/images/random/tb'.$random.'.jpg';
  }
  return $first_img;
}
作者: sense    时间: 2015-12-24 16:59
修改模板可以。




欢迎光临 全球主机交流论坛 (https://sunk.eu.org/) Powered by Discuz! X3.4