Skip to content

Commit

Permalink
feat: add supports for responsive image (#172)
Browse files Browse the repository at this point in the history
适配 Halo 2.19,支持响应式图片。

/kind feature

```release-note
适配 Halo 2.19,支持响应式图片。
```
  • Loading branch information
ruibaby authored Sep 4, 2024
1 parent 118d19e commit 65fbbee
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions templates/modules/featured-post-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<img
th:src="${post.spec.cover}"
th:alt="${post.spec.title}"
th:srcset="|${thumbnail.gen(post.spec.cover, 's')} 400w,
${thumbnail.gen(post.spec.cover, 'm')} 800w,
${thumbnail.gen(post.spec.cover, 'l')} 1200w,
${thumbnail.gen(post.spec.cover, 'xl')} 1600w|"
sizes="(max-width: 1600px) 100vw, 1600px"
class="size-full object-cover transition-all duration-500"
/>
</a>
Expand Down
4 changes: 4 additions & 0 deletions templates/modules/post-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<img
th:src="${post.spec.cover}"
th:alt="${post.spec.title}"
th:srcset="|${thumbnail.gen(post.spec.cover, 's')} 400w,
${thumbnail.gen(post.spec.cover, 'm')} 800w,
${thumbnail.gen(post.spec.cover, 'l')} 1200w|"
sizes="(max-width: 1200px) 100vw, 1200px"
class="size-full object-cover transition-all duration-500"
th:classappend="${animation} ? 'group-hover:scale-105'"
/>
Expand Down
4 changes: 4 additions & 0 deletions templates/moments.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ <h1 class="mb-9 text-2xl font-medium dark:text-slate-50">瞬间</h1>
th:if="${#strings.equals(media.type,'PHOTO')}"
class="transform-gpu rounded-lg object-cover"
th:src="${media.url}"
th:srcset="|${thumbnail.gen(media.url, 's')} 400w,
${thumbnail.gen(media.url, 'm')} 800w,
${thumbnail.gen(media.url, 'l')} 1200w|"
sizes="(max-width: 1200px) 100vw, 1200px"
/>
<div
th:if="${#strings.equals(media.type,'VIDEO')}"
Expand Down
4 changes: 4 additions & 0 deletions templates/photos.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ <h1 class="mb-9 text-2xl font-medium dark:text-slate-50">图库</h1>
<img
class="animated fadeIn transform-gpu rounded-lg transition-all"
th:src="${photo.spec.url}"
th:srcset="|${thumbnail.gen(photo.spec.url, 's')} 400w,
${thumbnail.gen(photo.spec.url, 'm')} 800w,
${thumbnail.gen(photo.spec.url, 'l')} 1200w|"
sizes="(max-width: 1200px) 100vw, 1200px"
th:alt="${photo.spec.displayName}"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
settingName: "theme-earth-setting"
configMapName: "theme-earth-configMap"
version: 1.9.1
requires: ">=2.8.0"
requires: ">=2.19.0"
license:
- name: "GPL-3.0"
url: "https://github.com/halo-dev/theme-earth/blob/main/LICENSE"

0 comments on commit 65fbbee

Please sign in to comment.