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.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
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
onerrorhandlers to swap broken<img>elements to fallback images - Set
this.onerror=nullinside 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.
Độ 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
Bình luận
- …
Thêm skill từ kho mã này
frontendchecklist
75kKiểm tra mã frontend và trang trực tiếp theo hơn 380 quy tắc về khả năng tiếp cận, tốc độ, SEO và bảo mật, bằng một công cụ dòng lệnh.
frontend-checklist-global
75kKiểm toán một dự án frontend theo đủ 386 quy tắc của Front-End Checklist, và đưa cách sửa cụ thể cho từng vấn đề tìm thấy.
404-page
75kKiểm tra xem trang báo thiếu của bạn có đưa ra các liên kết hữu ích và trả về mã trạng thái 404 thật hay không, để giúp khách bị lạc tìm đường.
about-page
75kKiểm tra xem trang web có trang Giới thiệu rõ ràng giải thích ai điều hành nó hay không, để xây dựng niềm tin với khách và công cụ tìm kiếm.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.