wordpress日常优化
来源:互联网 发布:c语言转汇编 编辑:程序博客网 时间:2024/06/11 11:14
1.禁用geogle字体
在主题中的 functions.php 文件中添加以下代码:
//关闭geogle字体
class Disable_Google_Fonts {
public function __construct() {
add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );
}
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
}
$disable_google_fonts = new Disable_Google_Fonts;
2.缩略图改为固定裁剪的缩略图
缩略图是通过deel_thumbnail函数进行提取的,一般在主题的functions.php中,没有对图片进行裁切压缩,下面是我优化后的函数代码
/*缩略图*/
if ( ! function_exists( 'deel_thumbnail' ) ) :
function deel_thumbnail() {
global $post;
if ( has_post_thumbnail() ) {
$domsxe = simplexml_load_string(get_the_post_thumbnail());
$thumbnailsrc = $domsxe->attributes()->src;
echo '<img width="220" height="150" src="'.$thumbnailsrc.'" alt="'.trim(strip_tags( $post->post_title )).'" />';
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img width="220" height="150" src="'.get_bloginfo("template_url").'/timthumb.php?src='.$strResult[1][0].'&w=220&h=150&zc=1" alt="'.trim(strip_tags( $post->post_title )).'" />';
}else {
echo '<img width="220" height="150" src="'.get_bloginfo('template_url').'/img/thumbnail.png" alt="'.trim(strip_tags( $post->post_title )).'" />';
}
}
}
endif;
改成固定大小220*150,具体裁剪是情况而定
- wordpress日常优化
- wordpress优化
- wordpress优化
- Unity 日常优化总结
- Wordpress的Url优化
- Wordpress性能优化
- WordPress优化之安全
- WordPress 优化方法大全
- Wordpress SEO 搜索引擎优化
- WordPress SEO优化技巧
- wordpress优化指南
- WordPress站点速度优化
- 140127 wordpress可视化优化
- WordPress数据库优化技巧
- WordPress 优化必备插件
- wordpress面向搜索引擎优化
- WordPress 简单优化
- wordpress优化头部
- 如何选择一个技术解决方案
- thinkphp3.2 layout 模板布局 路径问题
- Java list.romve方法bug
- jquery换一批的写法
- vue2.0之axios使用详解(一)
- wordpress日常优化
- 【Linux Kernel 进程管理】深入分析fork
- 115个Java面试题和答案——终极列表(下)
- ZOJ--3778--Talented Chef--数学智力题
- FZU Tic-Tac-Toe
- vue2.0之axios使用详解(二)
- 输入捕获模式
- ELasticsearch集群搭建
- 双向队列deque