1
0
Fork 0
mirror of https://github.com/yunluo/gdk.git synced 2024-05-23 08:32:18 +02:00

增加图片base64转化,优化摘要获取

This commit is contained in:
云落 2020-02-23 10:58:55 +08:00
parent 4fcf1b5acc
commit a58053f675

View file

@ -4,9 +4,9 @@
/** /**
* 获取摘要 * 获取摘要
*/ */
function gdk_print_excerpt($length, $post = null, $echo = true, $more = '...') function gdk_print_excerpt($length, $post = null, $echo = true, $more = '...') {
{ global $post;
$text = get_the_excerpt($post);//自带的摘要 $text = $post->post_excerpt;
if ('' == $text) { if ('' == $text) {
$text = get_the_content();//获取文字 $text = get_the_content();//获取文字
@ -20,7 +20,7 @@ function gdk_print_excerpt($length, $post = null, $echo = true, $more = '...')
$excerpt = wp_trim_words( $text, $length, $more ); $excerpt = wp_trim_words( $text, $length, $more );
if ($excerpt) { if ($excerpt) {
$result = $excerpt; $result = apply_filters( 'the_excerpt', $excerpt );
} }
if ($echo == true) { if ($echo == true) {
echo $result; echo $result;
@ -1218,4 +1218,12 @@ function gdk_tag_dropdown(){
$gdk_option_tags[$gdk_tag->term_id] = $gdk_tag->name; $gdk_option_tags[$gdk_tag->term_id] = $gdk_tag->name;
} }
return $gdk_option_tag; return $gdk_option_tag;
}
function base64EncodeImage ($image_file) {
$base64_image = '';
$image_info = getimagesize($image_file);
$image_data = file_get_contents($image_file);
$base64_image = 'data:' . $image_info['mime'] . ';base64,' . base64_encode($image_data);
return $base64_image;
} }