mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-22 16:16:39 +00:00
Adds alt text to status images
This commit is contained in:
parent
45a0bd79fd
commit
ff5a0f7bc2
5 changed files with 7 additions and 4 deletions
|
@ -227,7 +227,8 @@ def image_attachments_formatter(images_json):
|
|||
''' deserialize a list of images '''
|
||||
attachments = []
|
||||
for image in images_json:
|
||||
attachment = models.Attachment()
|
||||
caption = image.get('name')
|
||||
attachment = models.Attachment(caption=caption)
|
||||
image_field = image_formatter(image)
|
||||
attachment.image.save(*image_field, save=False)
|
||||
attachments.append(attachment)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.0.7 on 2020-11-24 17:46
|
||||
# Generated by Django 3.0.7 on 2020-11-24 19:39
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
@ -19,6 +19,7 @@ class Migration(migrations.Migration):
|
|||
('updated_date', models.DateTimeField(auto_now=True)),
|
||||
('remote_id', models.CharField(max_length=255, null=True)),
|
||||
('image', models.ImageField(blank=True, null=True, upload_to='status/')),
|
||||
('caption', models.TextField(blank=True, null=True)),
|
||||
('status', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='bookwyrm.Status')),
|
||||
],
|
||||
options={
|
||||
|
|
|
@ -159,6 +159,7 @@ class Attachment(BookWyrmModel):
|
|||
related_name='attachments'
|
||||
)
|
||||
image = models.ImageField(upload_to='status/', null=True, blank=True)
|
||||
caption = models.TextField(null=True, blank=True)
|
||||
|
||||
|
||||
class GeneratedNote(Status):
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{% if status.attachments %}
|
||||
<div>
|
||||
{% for attachment in status.attachments.all %}
|
||||
<img src="/images/{{ attachment.image }}">
|
||||
<img src="/images/{{ attachment.image }}" alt="{{ attachment.caption }}">
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
2
bw-dev
2
bw-dev
|
@ -61,7 +61,7 @@ case "$1" in
|
|||
;;
|
||||
migrate)
|
||||
execweb python manage.py rename_app fedireads bookwyrm
|
||||
execweb python manage.py migrate
|
||||
execweb python manage.py "$@"
|
||||
;;
|
||||
bash)
|
||||
execweb bash
|
||||
|
|
Loading…
Reference in a new issue