fix #119
This commit is contained in:
parent
55250f8e28
commit
2b4612493c
|
@ -1514,31 +1514,35 @@ 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
|
||||
);
|
||||
}
|
||||
$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(
|
||||
|
|
Loading…
Reference in New Issue