Add field for media alt
This commit is contained in:
parent
f7ab61cbee
commit
980f94cd7f
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2 on 2021-05-01 20:01
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0004_thought_media'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='thought',
|
||||
name='media_alt',
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
|
@ -11,6 +11,7 @@ class Thought(models.Model):
|
|||
posted = models.DateTimeField(auto_now_add=True)
|
||||
timezone_offset = models.IntegerField() # The number of minutes behind UTC we were when this was posted
|
||||
media = models.FileField(upload_to="", blank=True) # A single image, video, or sound clip per post
|
||||
media_alt = models.TextField(blank=True) # An optional transcription of the Thought's media
|
||||
|
||||
def get_media_type(self):
|
||||
if not self.media:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<span class="extended-text text">{{thought.extended_text}}</span>
|
||||
{% with file_type=thought.get_media_type %}
|
||||
{% if file_type == "png" or file_type == "jpeg" %}
|
||||
<img src="{{ thought.media.url }}" class="extended-media">
|
||||
<img src="{{ thought.media.url }}" class="extended-media" alt="{{ thought.media_alt }}">
|
||||
{% elif file_type == "m4a" or file_type == "mp3" or file_type == "aac" %}
|
||||
<audio controls src="{{ thought.media.url }}" class="extended-media"></audio>
|
||||
{% elif file_type == "mov" or file_type == "mp4" %}
|
||||
|
|
Loading…
Reference in New Issue