From a58053f675a29542675641b2baa09c04c04e9caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E8=90=BD?= Date: Sun, 23 Feb 2020 10:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87base64?= =?UTF-8?q?=E8=BD=AC=E5=8C=96,=E4=BC=98=E5=8C=96=E6=91=98=E8=A6=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/Common.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/functions/Common.php b/functions/Common.php index 9a804da..7c5a8ec 100644 --- a/functions/Common.php +++ b/functions/Common.php @@ -4,9 +4,9 @@ /** * 获取摘要 */ -function gdk_print_excerpt($length, $post = null, $echo = true, $more = '...') -{ - $text = get_the_excerpt($post);//自带的摘要 +function gdk_print_excerpt($length, $post = null, $echo = true, $more = '...') { + global $post; + $text = $post->post_excerpt; if ('' == $text) { $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 ); if ($excerpt) { - $result = $excerpt; + $result = apply_filters( 'the_excerpt', $excerpt ); } if ($echo == true) { echo $result; @@ -1218,4 +1218,12 @@ function gdk_tag_dropdown(){ $gdk_option_tags[$gdk_tag->term_id] = $gdk_tag->name; } 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; } \ No newline at end of file