Skip to content

Instantly share code, notes, and snippets.

@leavlzi
leavlzi / imgReady
Last active October 24, 2018 01:57
javascript图片预加载
// 更新:
// 05.27: 1、保证回调执行顺序:error > ready > load;2、回调函数this指向img本身
// 04-02: 1、增加图片完全加载后的回调 2、提高性能
/**
* 图片头数据加载就绪事件 - 更快获取图片尺寸
* @version 2011.05.27
* @author TangBin
* @see http://www.planeart.cn/?p=1121
* @param {String} 图片路径
add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );
@leavlzi
leavlzi / gist:6130090
Created August 1, 2013 10:05
// WordPress 为图片自动添加属性
add_filter('the_content', 'pirobox_gall_replace');
function pirobox_gall_replace ($content)
{
global $post;
$pattern = "/<img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)>/i";
$replacement = '<img$1src=$2$3.$4$5 class="img-responsive"$6>$7>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>透明测试</title>
<style>
*{
margin:0;
padding:0;
font-size:12px;
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
// 主题文件的路径
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
@leavlzi
leavlzi / gist:7228590
Last active October 24, 2018 01:56
CSS实现三角形缺口
<!DOCTYPE html>
<html>
<head>
<title>CSS实现三角形缺口</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<style type="text/css">
# wubi86.custom.yaml
#
# 在【五笔86】里使用Emoji表情
#
patch:
engine/translators:
- punct_translator
- r10n_translator
- reverse_lookup_translator
recognizer/patterns/reverse_lookup: "`[a-z]*$"
@leavlzi
leavlzi / add_user_id.php
Created June 27, 2017 17:05
Add the User ID column to the WordPress Users Table
/*
copy the following code to you current theme functions.php file:
*/
/*
* Adding the column
*/
function rd_user_id_column( $columns ) {
$columns['user_id'] = 'ID';
return $columns;
@leavlzi
leavlzi / custom-excerpt.php
Last active September 29, 2017 18:15
Function to make custom excerpt
//Replace
<?php the_content(); ?>
//with
<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 120,"......"); ?>
@leavlzi
leavlzi / wp-menu-no-ul-li.php
Created September 30, 2017 18:32
Delete Wordpress Menu div & ul & li
<?php echo str_replace("</li>", "", ereg_replace("<li[^>]*>", "", wp_nav_menu(array('container' => 'false', 'items_wrap' => '%3$s','theme_location' => 'nav', 'echo' => false)) )); ?>