diff --git a/README.md b/README.md index 0a7ab28..5b56427 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ In addition, entities contain contextual methods, as follows: * `next` get next post * `prev` get previous post * `image` get post image +* `thumbnail` get post thumbnail (defined under Settings->Assets->Image Transforms->Blog Thumbnail) * `excerpt` get post excerpt * `content` get post content (supports Matrix field rendering. See below) diff --git a/src/behaviors/PostFieldsBehavior.php b/src/behaviors/PostFieldsBehavior.php index a093cf5..2fae01e 100644 --- a/src/behaviors/PostFieldsBehavior.php +++ b/src/behaviors/PostFieldsBehavior.php @@ -17,6 +17,10 @@ public function getImage() return $this->owner->blogifyPostImage->one(); } + public function thumbnail() { + return $this->getImage()->setTransform(Handles::THUMBNAIL_TRANSFORM); + } + public function getExcerpt() { return $this->owner->blogifyPostExcerpt; diff --git a/src/templates/blogify/_partials/postThumbnail.twig b/src/templates/blogify/_partials/postThumbnail.twig deleted file mode 100644 index ca93dc2..0000000 --- a/src/templates/blogify/_partials/postThumbnail.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% do image.setTransform('blogifyThumbnail') %} -{{ image.title }} \ No newline at end of file diff --git a/src/templates/blogify/filters/_partials/postsList.twig b/src/templates/blogify/filters/_partials/postsList.twig index be01644..9d922e5 100644 --- a/src/templates/blogify/filters/_partials/postsList.twig +++ b/src/templates/blogify/filters/_partials/postsList.twig @@ -7,26 +7,27 @@
- {% include 'blogify/_partials/postThumbnail' with {image:post.image,class:'img-fluid rounded'} %} -
- {% for category in post.categories.all() %} - - {% endfor %} -

{{ post.title }}

-
{% endfor %} diff --git a/src/templates/blogify/listing/_entry.twig b/src/templates/blogify/listing/_entry.twig index 8ecab86..b17d8ce 100644 --- a/src/templates/blogify/listing/_entry.twig +++ b/src/templates/blogify/listing/_entry.twig @@ -19,27 +19,28 @@
{% endfor %} diff --git a/src/templates/blogify/post/_entry.twig b/src/templates/blogify/post/_entry.twig index 0d10d71..3bd94e8 100644 --- a/src/templates/blogify/post/_entry.twig +++ b/src/templates/blogify/post/_entry.twig @@ -100,7 +100,7 @@ {% for post in blogifyRecentPosts().limit(4).all() %}
  • - {% include 'blogify/_partials/postThumbnail' with {image: post.image, class:"mr-4"} %} + {{ post.thumbnail.title }}