adjust images preview loading in builder

pull/142/head
Pete Matsyburka 2 years ago
parent deef9c7d3b
commit 07e66a6e53

@ -23,7 +23,7 @@ class PreviewDocumentPageController < ActionController::API
io = Templates::ProcessDocument.generate_pdf_preview_from_file(attachment, file_path, params[:id].to_i)
render plain: io.tap(&:rewind).read
render plain: io.tap(&:rewind).read, content_type: 'image/jpeg'
end
def find_or_create_document_tempfile_path(attachment)

@ -126,6 +126,7 @@
:is-drag="!!dragFieldType"
:draw-field="drawField"
:editable="editable"
:base-url="baseUrl"
@draw="onDraw"
@drop-field="onDropfield"
@remove-area="removeArea"

@ -49,6 +49,11 @@ export default {
required: false,
default: null
},
baseUrl: {
type: String,
required: false,
default: ''
},
isDrag: {
type: Boolean,
required: false,
@ -62,6 +67,13 @@ export default {
}
},
computed: {
basePreviewUrl () {
if (this.baseUrl) {
return new URL(this.baseUrl).origin
} else {
return ''
}
},
numberOfPages () {
return this.document.metadata?.pdf?.number_of_pages || this.document.preview_images.length
},
@ -72,7 +84,7 @@ export default {
return this.previewImagesIndex[i] || {
metadata: lazyloadMetadata,
id: Math.random().toString(),
url: `/preview/${this.document.uuid}/${i}.jpg`
url: this.basePreviewUrl + `/preview/${this.document.uuid}/${i}.jpg`
}
})
},

Loading…
Cancel
Save