Reorganizing asset folders is one of those routine development tasks that often turns into an unexpected game of find-and-replace.
You move assets/images/hero.webp into assets/hero.webp, only to find out your CSS background-image: url(...), React import, and Markdown documentation all broke.
To solve this, I built Auto Image Path Updater, a lightweight VS Code extension that automatically updates image paths the moment you move a file.
The Problem with Manual Asset Relocation
-
Multiple Syntaxes: Modern web apps reference images in different ways: HTML
<img src>, CSSurl(), JS/TSimport, and Markdown. -
Path Complexity: Tracking relative offsets (
../../) or root-relative paths (/illustrations/) manually is error-prone. -
Collision Risk: If you have multiple files named
icon.pngorlogo.png, bulk find-and-replace can easily corrupt unrelated code.
How Auto Image Path Updater Solves This
The extension listens for file move events within your workspace and handles the path rewrites automatically.
Supported File Types & Syntaxes:
-
HTML:
src,href, andsrcsetattributes -
CSS / SCSS:
background-image: url(...)(quoted or unquoted) -
JS / TS / JSX / TSX: Static and dynamic
importstatements -
Markdown:
syntax - JSON: Configurations referencing image paths
Smart URL & Root-Relative Handling
For frameworks like Next.js, Vite, or React where images reside in a public/ directory and are referenced via root-relative paths (e.g., url("/illustrations/bg.webp")), the extension automatically recalculates the public URL path without breaking your project structure.
Quick Demo
Installation & Setup
No setup or configuration is required!
- Open VS Code.
- Press
Ctrl+P(orCmd+Pon macOS) and type:
ext install DeepakKN.auto-image-path-path-updater
- Move any image file across your workspace folders, and your files will update instantly.
Open Source
The project is fully open-source. Contributions, stars, and feedback are always welcome:
⭐ GitHub: Auto Image Path Updater Repository
📦 Marketplace: Auto Image Path Updater VS Code Extension
What features or framework integrations would you like to see next? Let me know in the comments!
Top comments (0)