diff --git a/packages/frontend/src/components/MkImgWithBlurhash.vue b/packages/frontend/src/components/MkImgWithBlurhash.vue
index 22619ba2fd..ebca855ed0 100644
--- a/packages/frontend/src/components/MkImgWithBlurhash.vue
+++ b/packages/frontend/src/components/MkImgWithBlurhash.vue
@@ -1,6 +1,5 @@
@@ -62,13 +61,9 @@ const offscreen = computed(() => {
}, [_offscreen]);
return _offscreen;
});
-let loaded = $ref(false);
let canvasWidth = $ref(props.width);
let canvasHeight = $ref(props.height);
-
-function onLoad() {
- loaded = true;
-}
+let url = $ref();
watch([() => props.width, () => props.height], () => {
const ratio = props.width / props.height;
@@ -83,6 +78,20 @@ watch([() => props.width, () => props.height], () => {
immediate: true,
});
+watch([() => props.src], () => {
+ if (url) {
+ URL.revokeObjectURL(url);
+ url = undefined;
+ }
+ if (props.src) {
+ fetch(props.src, { mode: 'no-cors' })
+ .then((res) => res.blob())
+ .then((blob) => {
+ url = URL.createObjectURL(blob);
+ });
+ }
+}, { immediate: true });
+
function draw() {
if (props.hash == null || !offscreen.value) return;
worker.postMessage({
@@ -103,7 +112,7 @@ onMounted(() => {
} else {
// 100ms後に画像の読み込みが完了していなければblurhashを描画する
setTimeout(() => {
- if (!loaded) {
+ if (!url) {
draw();
}
}, 100);