Communitygithub.com

brainzcode/premium-landing

从 Unsplash 获取免费、免版权的高质量图片——根据情绪而非名词搜索,针对页面插槽进行裁剪和缩放,并严格遵守 API 的热链接和下载跟踪要求。适用于页面需要英雄图、章节配图、头像或卡片图但未提供时;当占位灰块需要替换为真实图片时;或当需要为设计查找、挑选或替换照片时。

premium-landing 是什么?

该技能为 AI 代理提供了一套完整的从 Unsplash 获取商用授权图片的流程,特别针对落地页设计场景进行了优化。它解决了常见的图片源失效问题(如已退役的 source.unsplash.com),指导代理如何获取并安全使用 API 密钥,并强调了两个容易被忽略但必须遵守的 API 规则:使用 CDN 热链接而非自行托管图片,以及在实际使用图片时触发下载跟踪端点。技能的核心价值在于“按情绪而非按名词搜索”,这能帮助代理为特定设计(如咖啡烘焙工坊、财富咨询等)找到风格更贴合的图片,而不是千篇一律的模板化结果。此外,它还涵盖了根据设计需求(裁剪区域、色调范围、图片风格一致性)进行图片选择、使用 CDN 参数进行尺寸适配、编写有意义的 alt 文本以及提供完整的检查清单,确保最终产出的图片不仅高质量且完全合规。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/brainzcode/premium-landing/tree/HEAD/plugins/premium-landing/skills/stock-imagery

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

图片素材

一个落地页如果英雄图位置是灰色的占位符,那它就是不完整的。本技能涵盖了如何获取可免费用于商业用途、与设计匹配且不会在他人加载页面时出错的真实摄影图片。

大多数人的首选接口已失效

https://source.unsplash.com/1600x900/?coffee     →  HTTP 503

source.unsplash.com(无需密钥的随机图片接口)已经退役。它仍然出现在大量博客文章和旧模板中,但现在会返回 503。如果你在代码库中发现它,那是一个破损的图片,而不是一个可用的图片。

当你已经知道图片 ID 时,无需密钥即可正常使用的是 CDN 地址:

https://images.unsplash.com/photo-1447933601403-0c6688de566e?auto=format&fit=crop&w=1600&q=80

这会返回一张真正的图片。但你无法在没有密钥的情况下搜索,并且虚构图片 ID 是行不通的。因此:

获取密钥(两分钟,免费)

  1. 访问 https://unsplash.com/oauth/applications → 新建应用 → 接受条款
  2. 复制 Access Key(访问密钥)
  3. 导出为环境变量——切勿将其提交到代码:
export UNSPLASH_ACCESS_KEY="your_access_key"

演示档位为每小时 50 次请求,对于一个落地页来说已经足够。如果用户没有密钥,请明确告知并询问——不要默默降级为灰色方框,也不要伪造 URL。

curl -s -H "Authorization: Client-ID $UNSPLASH_ACCESS_KEY" \
  "https://api.unsplash.com/search/photos?query=coastal+fog&orientation=landscape&per_page=8" \
| python3 -c "
import json,sys
for p in json.load(sys.stdin)['results']:
    print(p['id'], p['width'], p['height'], '|', (p.get('alt_description') or '')[:60])
    print('   ', p['urls']['raw'])
    print('   ', p['user']['name'], p['links']['download_location'])
"

两个容易遗漏的 API 规则

1. 热链接使用 API 返回的 URL。 Unsplash API 条款要求使用他们的 CDN URL 而非自行托管图片文件。这违背了常规的“提供本地优化资源”的建议,但在你使用 API 期间,必须遵守该条款。如果客户需要自托管文件,请通过 Unsplash+ 授权照片或在别处购买——不要悄悄自行托管并心存侥幸。

2. 在图片实际使用时触发下载端点。 不是在预览时——是在它被最终展示时。这是摄影师获得使用记录的方式,也是 API 的使用条件,而非礼貌。

curl -s -H "Authorization: Client-ID $UNSPLASH_ACCESS_KEY" \
  "$DOWNLOAD_LOCATION"   # 搜索结果中的 links.download_location 值

许可边界

Unsplash 许可允许商业和非商业用途,无需获得许可也无需标注来源。但它不允许销售未经修改的副本,也不允许构建与之竞争的图片服务。照片中可能包含可识别的人物、商标或艺术品——Unsplash 不负责处理肖像权或财产权授权,因此对于任何暗示背书的内容(例如看起来像是顾客的人、感言照片),请改用已获得授权的图片。

虽然不强制要求标注来源,但这一行代码成本低廉且是正确做法:

<!-- 图片:张三 / Unsplash -->

精心选择

按字面名词搜索正是让页面看起来像模板的原因。“Coffee”会返回一万张雷同的拉花俯拍照。

按情绪搜索,而非按主体。 对于一个咖啡烘焙工坊,可以搜索 温暖工业风车间、正在操作的手、晨光室内。对于财富咨询,可以搜索 静谧建筑、安静极简室内、长阴影。

然后根据设计实际约束的三个方面进行筛选:

  • 方向与主体位置。 一个使用 object-fit: cover 裁剪的英雄图,其主体需要偏离中心或留有上下空间,否则裁剪会切断主体。在选择之前要检查主体所在位置——构图计算详见 ../landing-page/references/traps.md。
  • 色调范围。 叠加文本需要其背景区域始终为亮色或始终为暗色。一张杂乱的中间调照片会让任何文字颜色都显得不合适。
  • 统一摄影师或统一风格。 一个区域内的三张图片来自三位摄影师会显得像库存图片。优先选择来自同一组拍摄的多张照片,或色调一致的图片。

调整尺寸

Unsplash CDN 参数负责调整尺寸,因此请请求你实际显示的尺寸:

?auto=format&fit=crop&w=1600&q=80        英雄图
?auto=format&fit=crop&w=800&q=80         卡片图
?auto=format&fit=crop&w=192&h=192&q=80   头像(方形)

auto=format 会为支持的浏览器提供 WebP/AVIF 格式。对于响应式英雄图,请按 800/1200/1600/2000 的宽度生成一个 srcset,而不是向手机端发送一张 2000px 的图片。

替代文本

alt 描述的是图片展示了什么,供无法看到它的人使用。它不是关键词槽位,也不是图片标题。

<!-- 不推荐 -->
<img alt="咖啡烘焙工坊落地页英雄图">
<!-- 推荐 -->
<img alt="烘焙师在车间里将生咖啡豆倒入滚筒烘焙机">

如果图片是装饰性的,并且周围的文本已经说明了所有内容,请使用 alt="",这样屏幕阅读器会跳过它。空的 alt 是正确的;缺失 alt 则是不正确的。

检查清单

  • UNSPLASH_ACCESS_KEY 已设置,从未提交到代码
  • 搜索了情绪,而非字面名词
  • 已检查主体位置与插槽裁剪方式是否匹配
  • 色调范围在任何叠加文本下均可正常工作
  • 同一区域内的图片风格一致
  • 按照 API 要求使用 CDN URL 热链接——未自行托管
  • 对每张最终使用的图片均触发了 download_location
  • 尺寸参数与显示尺寸匹配;响应式英雄图使用了 srcset
  • 提供了有意义的替代文本,或装饰性图片使用了 alt=""
  • 对于任何暗示背书的内容,未假设已获得肖像权/财产权授权

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

brainzcode/premium-landing

Add a studio or agency build credit to a website footer — "Site by <Studio>" linking to the studio's site. Use when finishing or shipping a site, adding a footer, or when asked for an agency credit, build credit, designed-by line, or attribution. Covers wording, placement opposite the client's copyright, markup for each stack, styling from the host site's tokens, and the sitewide-footer-link SEO footprint when the same credit runs across many client sites.

brainzcode/premium-landing

Build a complete premium landing page, either replicated from a reference screenshot/URL or designed from a written brief, in HTML, React, Next.js or Astro. Use when asked to build, design, replicate or clone a landing page, marketing page, or one-page site; when handed a design screenshot or Figma/Pinterest reference to turn into code; or when a landing page needs a full premium pass. Covers design tokens, section patterns, the layout traps that silently break grids and marquees, and screenshot-based responsive verification from 320px to 1920px.

brainzcode/premium-landing

Add Lenis smooth scrolling to a site correctly — setup, anchor offsets for sticky headers, scroll locking for modals and menus, reduced-motion handling. Use when asked for smooth scroll, Lenis, momentum/eased scrolling, or when smooth scroll broke a sticky header, a modal lock, or anchor links. Includes the sticky-position trap that only appears at non-zero scroll.

brainzcode/premium-landing

Build true Apple-style liquid glass in the browser — real refraction via SVG displacement maps, chromatic dispersion, specular edges. Use when asked for liquid glass, glassmorphism, frosted/glass cards, glass navbars, or when a blur-based "glass" effect looks flat. Includes the performance trap that makes backdrop-filter stutter on scroll and the contrast trap that makes text unreadable on glass.

brainzcode/premium-landing

Build a premium mobile nav — a hamburger button that morphs into a close X, a full-screen overlay panel with staggered link reveal, scroll lock, focus trap, and reduced-motion handling. Use when asked for a mobile menu, hamburger/burger button, nav drawer, off-canvas menu, or when a menu loses scroll position, still scrolls behind on iOS, leaks Tab focus to the page underneath, or the close button stops responding. Includes the z-index trap that swallows the close button and the iOS rubber-band trap.

brainzcode/premium-landing

Rebuild a design accurately from a supplied reference — a screenshot, PDF page, mockup or live URL — by measuring it numerically instead of eyeballing it. Use when asked to replicate, clone, match or rebuild a design "exactly", "1 to 1" or "with no mistakes", or when a build drifts from its reference. Covers extracting the true content box from a padded screenshot, deriving element positions as percentages, solving object-fit framing, and knowing when a reference cannot be matched.

brainzcode/premium-landing

Ship link previews and favicons that actually work - Open Graph and Twitter card tags, a correctly framed 1200x630 share image, and a full favicon set (SVG, ICO, apple-touch, maskable manifest icons). Use when asked for social sharing, OG image, open graph, twitter card, link preview, share image, favicon, app icon, apple touch icon, or web manifest. Also use when a shared link previews blank, shows the wrong image, or a favicon will not appear. Includes the absolute-URL trap that silently blanks every preview and the font trap that breaks SVG favicons on other machines.

相关技能