Skip to content

Commit

Permalink
feat:add image cdn support
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfa committed Dec 31, 2024
1 parent 62ace91 commit 66b9c4a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 31 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

Hera is a simple single column wordpress theme with perfect performace and elegance design.

latest version : `0.0.13`
latest version : `0.0.14`

## Changelog

### 0.0.14

- add image cdn support

### 0.0.13

- improve responsive support
Expand Down
6 changes: 5 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

本主题禁止各种修改作者链接打包重新发布的行为。

最新版本 : `0.0.13`
最新版本 : `0.0.14`

## 更新日志

### 0.0.14

- 图片 CDN 支持

### 0.0.13

- 提升响应式支持
Expand Down
40 changes: 29 additions & 11 deletions modules/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

function hera_get_background_image($post_id, $width = null, $height = null)
{
global $heraSetting;
if (has_post_thumbnail($post_id)) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
$output = $timthumb_src[0];
} elseif (get_post_meta($post_id, '_banner', true)) {
$output = get_post_meta($post_id, '_banner', true);
} else {
$content = get_post_field('post_content', $post_id);
$defaltthubmnail = '//static.fatesinger.com/2018/05/q3wyes7va2ehq59y.JPG';
$defaltthubmnail = $heraSetting->get_setting('default_thumbnail');
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if ($n > 0) {
Expand All @@ -18,24 +19,26 @@ function hera_get_background_image($post_id, $width = null, $height = null)
$output = $defaltthubmnail;
}
}

if ($height && $width) {
// if (pure_get_setting('upyun')) {
$result = $output . "!/both/{$width}x{$height}";
// } else {
// $result = $output;
// }
} else {
if ($heraSetting->get_setting('upyun')) {
$output = $output . "!/both/{$width}x{$height}";
}

$result = $output;
}
if ($heraSetting->get_setting('oss')) {
$heraSetting = $output . "?x-oss-process=image/crop,w_{$width},h_{$height}";
}

return $result;
if ($heraSetting->get_setting('qiniu')) {
$output = $output . "?imageView2/1/w/{$width}/h/{$height}";
}
}
return $output;
}

function hera_is_has_image($post_id)
{
static $has_image;
global $post;
if (has_post_thumbnail($post_id)) {
$has_image = true;
} elseif (get_post_meta($post_id, '_banner', true)) {
Expand All @@ -53,3 +56,18 @@ function hera_is_has_image($post_id)

return $has_image;
}

/**
* Get post image count
*
* @since Hera 0.0.9
*
*/


function hera_get_post_image_count($post_id)
{
$content = get_post_field('post_content', $post_id);
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
return count($strResult[1]);
}
1 change: 0 additions & 1 deletion modules/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ function head_output()

function panther_image_zoom($content)
{
global $post;
$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
$replacement = '<a$1href=$2$3.$4$5 data-action="imageZoomIn" $6>$7</a>';
$content = preg_replace($pattern, $replacement, $content);
Expand Down
15 changes: 0 additions & 15 deletions modules/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,3 @@ function get_link_items()
}
return $result;
}

/**
* Get post image count
*
* @since Hera 0.0.9
*
*/


function hera_get_post_image_count($post_id)
{
$content = get_post_field('post_content', $post_id);
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
return count($strResult[1]);
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"autoprefixer": "^9.6.1",
"axios": "^0.19.2",
"del": "^5.1.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Theme URI: https://github.com/bigfa/hera
Author: bigfa
Author URI: https://github.com/bigfa
Description: theme 2025
Version: 0.0.13
Version: 0.0.14
Tags: Minimalism, Responsive
*/

0 comments on commit 66b9c4a

Please sign in to comment.