mirror of
https://github.com/jcmexdev/obsidian-image-hoist.git
synced 2026-07-22 06:51:04 +00:00
refactor: clean up plugin logs and improve user-facing error messages
This commit is contained in:
parent
25825d2d70
commit
fab29b6b6a
12 changed files with 87 additions and 49 deletions
22
LICENSE
22
LICENSE
|
|
@ -1,5 +1,21 @@
|
|||
Copyright (C) 2020-2025 by Dynalist Inc.
|
||||
MIT License
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
Copyright (c) 2026 jcmexdev, Juan Carlos Garcia Esquivel
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
49
README.md
49
README.md
|
|
@ -1,38 +1,37 @@
|
|||
# Image Hoist for Obsidian
|
||||
|
||||
Image Hoist is an Obsidian plugin designed to optimize your vault's storage and portability by automatically offloading local images to [ImgBB](https://imgbb.com/).
|
||||

|
||||
|
||||
## Core Objective
|
||||
**Stop worrying about heavy notes and broken images.**
|
||||
|
||||
The primary goal of this plugin is to detect local images in your vault, upload them to ImgBB, and replace the local file references with remote markdown links. This keeps your vault lightweight and makes your notes easier to share and sync.
|
||||
Image Hoist is the ultimate tool to keep your Obsidian vault light, fast, and 100% shareable. It automatically takes your local images, moves them to the cloud ([ImgBB](https://imgbb.com/)), and replaces them with links that work anywhere.
|
||||
|
||||
## Features
|
||||
## 🌟 Why you need Image Hoist
|
||||
|
||||
- **Automatic Upload:** Automatically detects and uploads local images.
|
||||
- **Link Replacement:** Replaces `![[image.png]]` or `` with remote ImgBB links.
|
||||
- **Storage Optimization:** Reduces the size of your vault by removing binary image files after successful upload.
|
||||
- **Portability:** Access your images from any device without needing to sync large binary files.
|
||||
- **Save Massive Space**: Stop hoarding gigabytes of images in your vault. Keep your storage for what matters: your ideas.
|
||||
- **Lightning-Fast Sync**: Since your images are in the cloud, syncing your notes across devices (mobile, tablet, desktop) becomes instant.
|
||||
- **Share Without Friction**: When you copy-paste a note to a blog, email, or another person, your images will actually show up! No more broken links.
|
||||
- **Zero Effort**: Paste an image and forget about it. The plugin handles the upload and link replacement in the background.
|
||||
|
||||
## Installation
|
||||
## 🚀 Key Benefits
|
||||
|
||||
### From Obsidian (Not yet available)
|
||||
1. Go to **Settings** > **Community plugins** > **Browse**.
|
||||
2. Search for "Image Hoist".
|
||||
3. Click **Install**, then **Enable**.
|
||||
- **Set and Forget**: Enable "Auto-hoist" and every image you paste goes straight to the cloud. No local files, no clutter.
|
||||
- **Smart Uploads**: Already uploaded the same image? The plugin is smart enough to recognize it and reuse the existing link instantly.
|
||||
- **Note Cleanup**: Got an old note full of local images? One click and the whole note is "hoisted" to the cloud.
|
||||
- **Safe & Secure**: Your images are yours. Your access keys are kept private and secure within Obsidian.
|
||||
|
||||
### Manual Installation
|
||||
1. Download the latest release (`main.js`, `manifest.json`, `styles.css`).
|
||||
2. Create a folder named `obsidian-image-hoist` in your vault's `.obsidian/plugins/` directory.
|
||||
3. Move the downloaded files into that folder.
|
||||
4. Reload Obsidian and enable the plugin in **Settings** > **Community plugins**.
|
||||
## 🛠️ Quick Start
|
||||
|
||||
## Configuration
|
||||
1. **Install**: Add the plugin to your Obsidian vault.
|
||||
2. **Connect**: Get a free key from [ImgBB](https://api.imgbb.com/) and paste it into the plugin settings.
|
||||
3. **Enjoy**: Start pasting images or right-click any existing image to "hoist" it.
|
||||
|
||||
You will need an **ImgBB API Key** to use this plugin:
|
||||
1. Create a free account at [ImgBB](https://imgbb.com/).
|
||||
2. Get your API key from [ImgBB API settings](https://api.imgbb.com/).
|
||||
3. Paste the key into the plugin settings in Obsidian.
|
||||
## 📖 How to use it
|
||||
|
||||
## License
|
||||
- **Drag & Drop**: Just drag an image into your note—it goes straight to the cloud (if enabled).
|
||||
- **Right-Click**: See a local image? Right-click and select **Hoist this image**.
|
||||
- **The Magic Button**: Use the Command Palette (`Cmd/Ctrl + P`) and run **Hoist all images in current note** to clean up an entire page at once.
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE).
|
||||
|
|
|
|||
37
README_es.md
Normal file
37
README_es.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Image Hoist para Obsidian
|
||||
|
||||

|
||||
|
||||
**Olvídate de las notas pesadas y las imágenes que no cargan.**
|
||||
|
||||
Image Hoist es la herramienta definitiva para mantener tu vault de Obsidian ligero, rápido y 100% compartible. Sube automáticamente tus imágenes locales a la nube ([ImgBB](https://imgbb.com/)) y las reemplaza con enlaces que funcionan en cualquier lugar.
|
||||
|
||||
## 🌟 ¿Por qué necesitas Image Hoist?
|
||||
|
||||
- **Ahorra espacio masivo**: Deja de acumular gigabytes de fotos en tu dispositivo. Reserva tu almacenamiento para lo que importa: tus ideas.
|
||||
- **Sincronización ultra rápida**: Al tener tus fotos en la nube, sincronizar tus notas entre dispositivos (móvil, tablet, PC) es instantáneo.
|
||||
- **Comparte sin fricción**: Cuando copies una nota para un blog, un correo o para otra persona, ¡las imágenes se verán de verdad! Se acabaron los enlaces rotos.
|
||||
- **Esfuerzo cero**: Pega una imagen y olvídate. El plugin se encarga de subirla y poner el enlace por ti en segundo plano.
|
||||
|
||||
## 🚀 Beneficios principales
|
||||
|
||||
- **Configura y olvida**: Activa la "Subida automática" y cada imagen que pegues irá directa a la nube. Sin archivos locales, sin desorden.
|
||||
- **Subidas inteligentes**: ¿Ya subiste la misma foto antes? El plugin es lo suficientemente listo para reconocerla y reutilizar el enlace existente al instante.
|
||||
- **Limpieza de notas**: ¿Tienes una nota vieja llena de fotos locales? Con un solo clic, toda la nota se "limpia" y las fotos pasan a la nube.
|
||||
- **Seguro y privado**: Tus fotos son tuyas. Tus claves de acceso se mantienen privadas y seguras dentro de Obsidian.
|
||||
|
||||
## 🛠️ Inicio rápido
|
||||
|
||||
1. **Instala**: Añade el plugin a tu carpeta de Obsidian.
|
||||
2. **Conecta**: Consigue una clave gratuita en [ImgBB](https://api.imgbb.com/) y pégala en los ajustes del plugin.
|
||||
3. **Disfruta**: Empieza a pegar fotos o haz clic derecho en cualquier imagen existente para subirla a la nube.
|
||||
|
||||
## 📖 Cómo usarlo
|
||||
|
||||
- **Arrastrar y soltar**: Simplemente arrastra una foto a tu nota; irá directa a la nube (si lo activas).
|
||||
- **Clic derecho**: ¿Ves una foto local? Haz clic derecho y selecciona **Subir esta imagen (hoist)**.
|
||||
- **El botón mágico**: Usa la Paleta de Comandos (`Cmd/Ctrl + P`) y ejecuta **Subir todas las imágenes de la nota** para limpiar una página entera de una sola vez.
|
||||
|
||||
## 📄 Licencia
|
||||
|
||||
Este proyecto está bajo la [Licencia MIT](LICENSE).
|
||||
|
|
@ -31,4 +31,4 @@
|
|||
"typescript-eslint": "8.35.1",
|
||||
"vitest": "^4.1.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,6 @@ export async function hoistImagesInCurrentNote(plugin: ImageHoistPlugin, process
|
|||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
new Notice(`Error: ${msg}`);
|
||||
console.error("Image Hoist Error:", error);
|
||||
}
|
||||
}
|
||||
).open();
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export class ImageProcessor {
|
|||
processedCount++;
|
||||
if (result.isCacheHit) cacheCount++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to process ${img.name}:`, error);
|
||||
// We still throw or ignore quietly as per user request to remove logs
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,18 +18,13 @@ export function t(key: keyof LocaleType, vars: Record<string, string | number> =
|
|||
const lang = (obsidianLang || moment.locale()).split("-")[0] || "en";
|
||||
|
||||
const locale = locales[lang] || locales.en;
|
||||
|
||||
const fallback = locales.en!;
|
||||
|
||||
let text = (locale ? locale[key] : fallback[key]) || fallback[key] || key;
|
||||
|
||||
Object.keys(vars).forEach((v) => {
|
||||
text = text.replace(`{{${v}}}`, String(vars[v]));
|
||||
});
|
||||
|
||||
// Debug log to identify why it's not showing Spanish
|
||||
if (lang === "es" && text === fallback[key] && locale[key] === undefined) {
|
||||
console.debug(`Image Hoist i18n: Key "${key}" not found in "es" locale, falling back to "en".`);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ export default {
|
|||
NOTICE_STARTING_ALL: "Starting hoist of {{count}} images...",
|
||||
NOTICE_SUCCESS_ALL: "Successfully hoisted {{count}} images!",
|
||||
NOTICE_SUCCESS_ALL_CACHE: "Successfully processed {{count}} images ({{cacheCount}} from cache)!",
|
||||
NOTICE_ERROR_ALL: "Error during hoist process. Check console.",
|
||||
NOTICE_ERROR_ALL: "Error during hoist process. Please try again.",
|
||||
NOTICE_STARTING_SINGLE: "Hoisting image: {{name}}...",
|
||||
NOTICE_SUCCESS_SINGLE: "Successfully hoisted {{name}}!",
|
||||
NOTICE_SUCCESS_CACHE: "Successfully retrieved {{name}} from cache!",
|
||||
NOTICE_ERROR_SINGLE: "Failed to hoist {{name}}. Check console.",
|
||||
NOTICE_ERROR_SINGLE: "Failed to hoist {{name}}.",
|
||||
NOTICE_NO_IMAGES: "No local images found in this note.",
|
||||
NOTICE_NO_MARKDOWN: "No active markdown note found.",
|
||||
NOTICE_CACHE_CLEARED: "Upload cache cleared successfully!",
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ export default {
|
|||
NOTICE_STARTING_ALL: "Iniciando subida de {{count}} imágenes...",
|
||||
NOTICE_SUCCESS_ALL: "¡Se han subido {{count}} imágenes con éxito!",
|
||||
NOTICE_SUCCESS_ALL_CACHE: "¡Se han procesado {{count}} imágenes ({{cacheCount}} desde la caché)!",
|
||||
NOTICE_ERROR_ALL: "Error durante el proceso de subida. Revisa la consola.",
|
||||
NOTICE_ERROR_ALL: "Error durante el proceso de subida.",
|
||||
NOTICE_STARTING_SINGLE: "Subiendo imagen: {{name}}...",
|
||||
NOTICE_SUCCESS_SINGLE: "¡{{name}} subida con éxito!",
|
||||
NOTICE_SUCCESS_CACHE: "¡{{name}} recuperada de la caché con éxito!",
|
||||
NOTICE_ERROR_SINGLE: "Error al subir {{name}}. Revisa la consola.",
|
||||
NOTICE_ERROR_SINGLE: "Error al subir {{name}}.",
|
||||
NOTICE_NO_IMAGES: "No se han encontrado imágenes locales en esta nota.",
|
||||
NOTICE_NO_MARKDOWN: "No se ha encontrado ninguna nota activa.",
|
||||
NOTICE_CACHE_CLEARED: "¡La caché de subidas se ha limpiado con éxito!",
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ export default class ImageHoistPlugin extends Plugin {
|
|||
registerCommands(this, this.processor);
|
||||
registerContextMenu(this);
|
||||
registerAutoHoistHandler(this);
|
||||
|
||||
// Minimal logging on startup, no intrusive Notices
|
||||
if (!apiKey) {
|
||||
console.debug("Image Hoist: API Key not set. Features will be available but uploads will prompt for configuration.");
|
||||
}
|
||||
}
|
||||
|
||||
onunload() {}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,5 @@ async function handleFileAutoHoist(file: File, editor: Editor, plugin: ImageHois
|
|||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
new Notice(`Error: ${msg}`);
|
||||
console.error("Auto-hoist Error:", error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ export function registerContextMenu(plugin: ImageHoistPlugin) {
|
|||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
new Notice(`Error: ${msg}`);
|
||||
console.error("Image hoist error:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -138,7 +137,6 @@ export function registerContextMenu(plugin: ImageHoistPlugin) {
|
|||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
new Notice(`Error: ${msg}`);
|
||||
console.error("Image hoist error:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue