Fix image block in front-end

This commit is contained in:
Ramon Wenger 2018-09-27 11:29:01 +02:00
parent fd40813a40
commit 65d50f686c
2 changed files with 12 additions and 10 deletions

View File

@ -26,14 +26,15 @@
computed: { computed: {
image() { image() {
if (this.contents) { if (this.contents) {
let found = this.contents.find(c => c.type === 'image_url'); let found = this.contents.find(c => c.type === 'image_url_block');
return found ? found.value.url : ''; return found ? found.value.url : '';
} }
return ''; return '';
}, },
teaser() { teaser() {
if (this.contents && this.contents.length) { if (this.contents && this.contents.length) {
let first = this.contents.find(content => content.type !== 'image_url'); let first = this.contents.find(content => content.type !== 'image_url_block');
if (first && first.type) {
switch (first.type) { switch (first.type) {
case 'text_block': case 'text_block':
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...'; return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
@ -44,6 +45,7 @@
return '' return ''
} }
} }
}
return ''; return '';
} }
} }

View File

@ -31,7 +31,7 @@ class RoomEntry(TitleSlugDescriptionModel):
contents = StreamField([ contents = StreamField([
('text_block', TextBlock()), ('text_block', TextBlock()),
('image_url', ImageUrlBlock()), ('image_url_block', ImageUrlBlock()),
('link_block', LinkBlock()), ('link_block', LinkBlock()),
('video_block', VideoBlock()) ('video_block', VideoBlock())
], null=True, blank=True) ], null=True, blank=True)