icosa-foundation / icosa-gallery

Icosa Gallery is a 3D model hosting solution, intended as a replacement for Google's Poly
https://icosa.gallery
Apache License 2.0
8 stars 0 forks source link

Update thumbnail from "edit asset" screen #53

Open andybak opened 1 month ago

andybak commented 1 month ago

I've added support to the viewer component. Here's example usage:

function updateThumbnail() {
    let dataURL = viewer.captureThumbnail(512, 384);
    let imageBlob = viewer.dataURLtoBlob(dataURL);
    let img = document.getElementsByClassName('img-preview')[0];
    img.src = dataURL;
    let formData = new FormData();
    formData.append('file', imageBlob, 'thumbnail.png');
    fetch(window.location + '/updateThumbnail', {
        method: 'POST',
        body: formData
    })
        .then(response => response.json())
        .then(data => {
            console.log('Upload successful:', data);
        })
        .catch((error) => {
            console.error('Error uploading image:', error);
        });
}

This code should update the thumbnail preview on the page and also POST a blob to a (non-existent) endpoint.

andybak commented 1 month ago

Admins also need a way to do this for assets they don't own. Maybe the "edit" page can accept a superuser override?