Skip to content

Commit

Permalink
refactor: adding the image component for show image in post
Browse files Browse the repository at this point in the history
  • Loading branch information
rzashakeri committed Jul 2, 2022
1 parent 7d6283d commit d393bd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 10 additions & 0 deletions post/templates/post/components/image_component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% load thumbnail %}
{% if post.image.file|is_portrait %}
{% thumbnail post.image.file "521x521" crop="center" quality=100 as img %}
<img class="w-fit portrait" src="{{ img.url }}" alt="">
{% endthumbnail %}
{% else %}
{% thumbnail post.image.file "521x521" quality=100 as img %}
<img class="w-fit" src="{{ img.url }}" alt="">
{% endthumbnail %}
{% endif %}
11 changes: 1 addition & 10 deletions post/templates/post/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@
</div>
<div class="w-full">
{% if post.image %}
{% if post.image.file|is_portrait %}
{% thumbnail post.image.file "521x521" crop="center" quality=100 as img %}
<img class="w-fit portrait" src="{{ img.url }}" alt="">
{% endthumbnail %}
{% else %}
{% thumbnail post.image.file "521x521" quality=100 as img %}
<img class="w-fit" src="{{ img.url }}" alt="">
{% endthumbnail %}
{% endif %}
{% include "post/components/image_component.html" %}
{% elif post.audio %}
{% include "post/components/audio_component.html" %}
{% elif post.video %}
{% include "post/components/video_component.html" %}
{% endif %}


</div>

<p>{{ post.caption }}</p>
Expand Down

0 comments on commit d393bd6

Please sign in to comment.