Fix image block in front-end
This commit is contained in:
parent
fd40813a40
commit
65d50f686c
|
|
@ -26,22 +26,24 @@
|
||||||
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');
|
||||||
switch (first.type) {
|
if (first && first.type) {
|
||||||
case 'text_block':
|
switch (first.type) {
|
||||||
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
|
case 'text_block':
|
||||||
|
return first.value.text.replace(/<p>/g, '').replace(/<\/p>/g, '<br>').slice(0, 75) + '...';
|
||||||
// return first.value.text;
|
// return first.value.text;
|
||||||
case 'link_block':
|
case 'link_block':
|
||||||
return first.value.url;
|
return first.value.url;
|
||||||
default:
|
default:
|
||||||
return ''
|
return ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue