Skip to content

Commit

Permalink
mediahubPhoto.js, display last images
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio-Emmolo committed Jun 25, 2024
1 parent b0b394d commit c1a54ee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/mediahubPhoto.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ tinymce.PluginManager.add('mediahubPhoto', function (editor, url) {
]
}
})
lastImage()
// Search Image
searchImages()
// Insert into editor
Expand All @@ -130,6 +131,31 @@ tinymce.PluginManager.add('mediahubPhoto', function (editor, url) {
})

// === FUNCTIONS === //
async function lastImage (editor) {

const container = document.querySelector('#card-container')

const results = await fetch('/nova-vendor/media-hub/media', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
if (response.ok) {
return response.json()
} else {
throw new Error('Error in Nova API Request')
}
}
// Debug response
).then(function (data) {
console.log(data.data)
return data.data
})

sliderDimensions(3)
printCards(results, container)
}
function searchImages (query) {
const formQuery = document.querySelector('.tox-dialog__content-js form#query')
const container = document.querySelector('#card-container')
Expand Down

0 comments on commit c1a54ee

Please sign in to comment.