Refactor image fetching in Banner and Logo editors to use our API client
This commit is contained in:
@@ -115,11 +115,13 @@ const onFileSelected = (event) => {
|
||||
|
||||
const startEditing = () => {
|
||||
if (fileUrl.value && fileUrl.value !== fallbackUrl) {
|
||||
// Create a temporary file from the current image URL
|
||||
fetch(fileUrl.value)
|
||||
.then(res => res.blob())
|
||||
.then(blob => {
|
||||
// Use our API client to get the image
|
||||
client.get(fileUrl.value, { responseType: 'blob' })
|
||||
.then(response => {
|
||||
const blob = response.data
|
||||
selectedFile.value = new File([blob], 'current-image.jpg', { type: 'image/jpeg' })
|
||||
// Create a local URL for the cropper
|
||||
fileUrl.value = URL.createObjectURL(blob)
|
||||
showCropper.value = true
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -118,11 +118,13 @@ const onFileSelected = (event) => {
|
||||
|
||||
const startEditing = () => {
|
||||
if (fileUrl.value && fileUrl.value !== fallbackUrl) {
|
||||
// Create a temporary file from the current image URL
|
||||
fetch(fileUrl.value)
|
||||
.then(res => res.blob())
|
||||
.then(blob => {
|
||||
// Use our API client to get the image
|
||||
client.get(fileUrl.value, { responseType: 'blob' })
|
||||
.then(response => {
|
||||
const blob = response.data
|
||||
selectedFile.value = new File([blob], 'current-image.jpg', { type: 'image/jpeg' })
|
||||
// Create a local URL for the cropper
|
||||
fileUrl.value = URL.createObjectURL(blob)
|
||||
showCropper.value = true
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user