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,22 +26,24 @@
computed: {
image() {
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 '';
},
teaser() {
if (this.contents && this.contents.length) {
let first = this.contents.find(content => content.type !== 'image_url');
switch (first.type) {
case 'text_block':
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
let first = this.contents.find(content => content.type !== 'image_url_block');
if (first && first.type) {
switch (first.type) {
case 'text_block':
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
// return first.value.text;
case 'link_block':
return first.value.url;
default:
return ''
case 'link_block':
return first.value.url;
default:
return ''
}
}
}
return '';

View File

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