Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thumbnail from "edit asset" screen #53

Open
andybak opened this issue Sep 14, 2024 · 1 comment
Open

Update thumbnail from "edit asset" screen #53

andybak opened this issue Sep 14, 2024 · 1 comment
Assignees

Comments

@andybak
Copy link
Contributor

andybak commented Sep 14, 2024

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
Copy link
Contributor Author

andybak commented Sep 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants