pull/121/head
spirit 2019-10-28 20:52:29 +08:00
parent 55250f8e28
commit 2b4612493c
1 changed files with 23 additions and 19 deletions

View File

@ -1513,32 +1513,36 @@ function codecheese_register_post( $sanitized_user_login, $user_email, $errors )
// html 标签处理器
function html_tag_parser($content) {
if(!is_feed()) {
if(akina_option('lazyload') && akina_option('lazyload_spinner')){
$content=preg_replace(
'/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i',
"<img $1 class=\"lazyload\" data-src=\"$2\" src=\"".akina_option('lazyload_spinner')."\" onerror=\"imgError(this)\" $3 >\n<noscript>$0</noscript>",
$content
);
}
if(!is_feed()) {
$content=preg_replace(
'/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i',
"<img $1 class=\"lazyload\" data-src=\"$2\" src=\"https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg\" onerror=\"imgError(this)\" $3 >\n<noscript>$0</noscript>",
$content
);
//Fancybox
/* Markdown Regex Pattern for Matching URLs:
* https://daringfireball.net/2010/07/improved_regex_for_matching_urls
*/
$url_regex ='(((http|https):\/\/)?(\w(\:\w)?@)?([0-9a-z_-]+\.)*?([a-z0-9-]+\.[a-z]{2,6}(\.[a-z]{2})?(\:[0-9]{2,6})?)((\/[^?#<>\/\\*":]*)+(\?[^#]*)?(#.*)?)?)';
$url_regex ='((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))';
//With Thumbnail: !{alt}(url)[th_url]
$content=preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$15" target="_blank" rel="nofollow" class="fancybox"></a>',
$content
);
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
$i=0;
foreach ($matches as $val) {
$content=str_replace($val[$i],preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$7" target="_blank" rel="nofollow" class="fancybox"></a>',
$val[$i]),
$content);
$i++;
}
}
//Without Thumbnail :!{alt}(url)
$content=preg_replace(