diff --git a/public/site/plugins/helpers/index.php b/public/site/plugins/helpers/index.php
index 616dbc2..d460123 100644
--- a/public/site/plugins/helpers/index.php
+++ b/public/site/plugins/helpers/index.php
@@ -8,6 +8,7 @@ function getFileData($file) {
'quality' => 80,
'format' => 'webp'
])->url(),
+ 'source' => $file->url(),
'parent' => [
"title" => (string) $file->parent()->title(),
"uri" => $file->parent()->uri()
@@ -28,10 +29,10 @@ function getFileData($file) {
$data['tags'] = $file->tags()->split();
};
- if($file->comments()->exists()) {
+ if ($file->comments()->exists()) {
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
- }
+ }
return $data;
}
\ No newline at end of file
diff --git a/src/components/project/virtual-sample/Interactive360.vue b/src/components/project/virtual-sample/Interactive360.vue
index fd74ada..a590c92 100644
--- a/src/components/project/virtual-sample/Interactive360.vue
+++ b/src/components/project/virtual-sample/Interactive360.vue
@@ -43,6 +43,7 @@ const { activeTrack } = defineProps({
// Helper
const { openedFile } = storeToRefs(useDialogStore());
const virtualSampleStore = useVirtualSampleStore();
+const { isDownloadTriggered } = storeToRefs(useVirtualSampleStore());
const isHelperHidden = ref(localStorage.getItem("isHelperHidden"));
localStorage.setItem("isHelperHidden", true);
@@ -187,4 +188,16 @@ function preloadImages() {
image.src = imageUrl;
});
}
+
+// Download image
+watch(isDownloadTriggered, (newValue) => {
+ if (!newValue) return;
+
+ const downloadNode = document.createElement("a");
+ downloadNode.setAttribute("href", currentFile.value.source);
+ downloadNode.setAttribute("download", "");
+ document.body.appendChild(downloadNode);
+ downloadNode.click();
+ document.body.removeChild(downloadNode);
+});
diff --git a/src/components/project/virtual-sample/VirtualSample.vue b/src/components/project/virtual-sample/VirtualSample.vue
index 7a01def..6deeefd 100644
--- a/src/components/project/virtual-sample/VirtualSample.vue
+++ b/src/components/project/virtual-sample/VirtualSample.vue
@@ -44,18 +44,15 @@
-
- {{
- activeTab === "dynamic" ? "Télécharger l’image" : "Télécharger le PDF"
- }}
-
+ {{ downloadText }}
+