Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2760

broken-images

Skill này làm gì

Skill này kiểm tra các tham chiếu ảnh của dự án xem có tệp bị thiếu hoặc đường dẫn sẽ lỗi không. Skill dành cho lập trình viên web và chủ website muốn ảnh tải ổn định.

Khi nào nên dùng

  • ✓Khi người xem thấy biểu tượng ảnh lỗi trên trang.
  • ✓Khi đường dẫn ảnh trỏ tới một tệp không có trong dự án.
  • ✓Khi ảnh đến từ dữ liệu người dùng hoặc link ngoài có thể biến mất.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/broken-images/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/broken-images/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy quét dự án của tôi để tìm đường dẫn ảnh trỏ tới tệp bị thiếu và thêm phương án dự phòng khi cần.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra thuộc tính nguồn ảnh và ảnh nền xem có tệp bị thiếu không, sửa đường dẫn sai, và thêm trình xử lý lỗi để thay bằng ảnh dự phòng khi cần.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Fix broken images

A broken image shows an ugly placeholder icon, breaks visual layouts, and communicates that the site is poorly maintained. If the broken image is the Largest Contentful Paint element, it also harms LCP scores. On e-commerce sites, a missing product image can directly reduce purchase intent.

Quick Reference

  • Broken images show an icon and console error—validate all <img src> paths at build time
  • Use onerror handlers to swap broken <img> elements to fallback images
  • Set this.onerror=null inside the handler to prevent infinite error loops
  • Test with DevTools Network tab blocked requests to verify fallback behaviour

Check

Scan all <img> src attributes and CSS background-image URLs in this codebase. Identify: 1) Any relative or absolute paths that point to files not present in the project. 2) Any <img> elements without an onerror handler or fallback mechanism. 3) Hardcoded external image URLs that may become unavailable. 4) Dynamic image paths constructed from user data without existence checks. Report each broken or potentially broken image with its file path and line number.

Fix

For each broken image: 1) Correct the file path if the image exists but the path is wrong. 2) Add the missing image asset if it was omitted. 3) For images that may fail at runtime, add an onerror handler: onerror="this.src='/images/fallback.png'; this.onerror=null;". 4) For React/Vue components, implement an onError callback that swaps the src to a placeholder. 5) For external images, consider downloading and self-hosting or using a CDN with fallback. Always set this.onerror=null to prevent infinite error loops.

Explain

Explain why broken images degrade user experience and how browsers handle them. A 404 response for an image shows the browser's broken-image icon, causes a console error, and—if the image is the LCP element—delays Core Web Vitals metrics. Search engines cannot index missing images, affecting image SEO. Monitoring image errors proactively prevents broken experiences from reaching users.

Code Review

Review image assets, markup, and delivery configuration related to Fix broken images. Flag exact files or components where format choice, sizing, or loading behavior violates the rule, and describe how to confirm the fix in DevTools.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/images/broken-images

Câu hỏi thường gặp

Ảnh lỗi quan trọng ở chỗ nào ngoài vẻ ngoài?

Skill nói nếu ảnh chính của trang bị lỗi, nó có thể làm giảm điểm tải trang.

Trình xử lý lỗi làm gì?

Nó thay ảnh dự phòng nếu ảnh gốc không tải được, và được thiết lập để không bị lặp vô tận.

Tôi có thể thử phương án dự phòng bằng cách nào?

Skill gợi ý chặn các yêu cầu trong công cụ dành cho nhà phát triển của trình duyệt để xem ảnh dự phòng hoạt động.

Chi tiết

Mô tả gốc của tác giả

Use when reviewing image assets, markup, and CDN or build transforms related to Fix broken images. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2760
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự