完成显示水印功能;

This commit is contained in:
2024-02-18 15:41:14 +08:00
parent a59b124e70
commit aa9ae7f30b
8 changed files with 150 additions and 32 deletions

View File

@@ -8,7 +8,6 @@ class PostShow
{
public static function handleCopyright($content)
{
// 防采集版权声明,被采集了会在其他网站显示
// 可以被选中复制,可以被采集,在网页中不会显示,但是在别的网站中可以显示
$content_copyright = '<blockquote class="post-content-inner-copyright"> 版权声明:' . get_system_config('post_copyright') . '</blockquote>';
@@ -27,13 +26,10 @@ class PostShow
$p_list = $dom_content->children('p');
foreach ($p_list as $index_p => $dom_p) {
if ($index_p != 0 && $index_p % 8 == 0) {
// $dom_copyright->clone()->children()->insertAfter($dom_p);
}
if ($index_p != 0 && $index_p % 6 == 0) {
$dom_copyright_hide->clone()->children()->insertAfter($dom_p);
}
}
@@ -42,4 +38,27 @@ class PostShow
return $content;
}
public static function handleImage($content)
{
$dom_content = phpQuery::newDocumentHTML($content);
$img_list = $dom_content->find('img');
foreach ($img_list as $index_img => $dom_img) {
$dom_img = pq($dom_img);
$src = $dom_img->attr('src');
$src = get_source_link($src);
$watermarked_file_save_name = Image::handelWatermarkSave($src);
$dom_img->attr('src', $watermarked_file_save_name);
}
$content = $dom_content->html();
return $content;
}
}