From c1a54ee0f25f889cb3a8ab11e1b4720fff181d7d Mon Sep 17 00:00:00 2001 From: Claudio-Emmolo <113107618+Claudio-Emmolo@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:24:51 +0200 Subject: [PATCH] mediahubPhoto.js, display last images --- src/mediahubPhoto.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mediahubPhoto.js b/src/mediahubPhoto.js index 664b7a3..9f0a807 100644 --- a/src/mediahubPhoto.js +++ b/src/mediahubPhoto.js @@ -110,6 +110,7 @@ tinymce.PluginManager.add('mediahubPhoto', function (editor, url) { ] } }) + lastImage() // Search Image searchImages() // Insert into editor @@ -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')