Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): use delivered cover_image for blog banners (#42173)

Coding On Star98d9298828d2
diff --git a/packages/contracts/marketplace.ts b/packages/contracts/marketplace.ts
index 06353129a8f..881af8e72ec 100644
--- a/packages/contracts/marketplace.ts
+++ b/packages/contracts/marketplace.ts
@@ -317,6 +317,7 @@ export type BannerBlog = BannerBase & {
blog_title: string
subtitle?: string
description?: string
+ cover_image?: string
link: string
link_target_type: 'blog' | 'github'
}
diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending-layout.browser.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending-layout.browser.spec.tsx
index dee188a39ed..b816cf7fda7 100644
--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending-layout.browser.spec.tsx
+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending-layout.browser.spec.tsx
@@ -14,6 +14,7 @@ const createBlogBanner = (id: string, title: string, sort: number): PluginBanner
blog_title: title,
subtitle: 'New Agent node support',
description: 'Build agent workflows with the new Agent node.',
+ cover_image: '/api/v1/banners/images/banners/blog-cover.png',
link: 'https://dify.ai/blog',
link_target_type: 'blog',
},
@@ -94,6 +95,7 @@ describe('Marketplace home trending layout', () => {
blog_title: longTitle,
subtitle: subtitleText,
description: descriptionText,
+ cover_image: '/api/v1/banners/images/banners/blog-cover.png',
link: 'https://dify.ai/blog',
link_target_type: 'blog',
},
diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending-swipe.browser.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending-swipe.browser.spec.tsx
index ca2f7d81983..f2ffb715f9c 100644
--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending-swipe.browser.spec.tsx
+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending-swipe.browser.spec.tsx
@@ -13,6 +13,7 @@ const createBanner = (id: string, title: string, sort: number): PluginBanner =>
blog_title: title,
subtitle: `${title} subtitle`,
description: `${title} description`,
+ cover_image: '/api/v1/banners/images/banners/blog-cover.png',
link: `https://example.com/${id}`,
link_target_type: 'blog',
},
diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
index ac1d6294811..dd5f2736541 100644
--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx
@@ -208,6 +208,41 @@ describe('HomeTrending', () => {
)
})
+ it('renders the delivered blog cover instead of bundled art', () => {
+ const blogBanner: PluginBanner = {
+ id: 'blog-cover',
+ style_type: 'blog',
+ title: 'Research',
+ sort: 0,
+ language: 'en',
+ content: {
+ blog_title: 'Trust Is a Feature',
+ subtitle: 'Security and governance',
+ link: 'https://dify.ai/blog/trust',
+ link_target_type: 'blog',
+ cover_image: '/api/v1/banners/images/banners/trust-cover.png',
+ },
+ }
+
+ render(<HomeTrending banners={[blogBanner]} isMarketplacePlatform page="plugins" />)
+
+ const blogLink = screen.getByRole('link', {
+ name: 'plugin.marketplace.home.trendingReadMoreAbout',
+ })
+ expect(blogLink.querySelector('img')?.getAttribute('src')).toContain(
+ '/api/v1/banners/images/banners/trust-cover.png',
+ )
+ })
+
+ it('omits blog cover art when the payload has no cover_image', () => {
+ render(<HomeTrending banners={[banners[1]!]} isMarketplacePlatform page="plugins" />)
+
+ const blogLink = screen.getByRole('link', {
+ name: 'plugin.marketplace.home.trendingReadMoreAbout',
+ })
+ expect(blogLink.querySelector('img')).toBeNull()
+ })
+
it('fits recommend card icons inside the frame instead of cover-cropping them', () => {
render(<HomeTrending banners={banners} isMarketplacePlatform page="plugins" />)
diff --git a/web/app/components/plugins/marketplace/home/assets/dify-updates-art.png b/web/app/components/plugins/marketplace/home/assets/dify-updates-art.png
deleted file mode 100644
index 12d192cef36..00000000000
Binary files a/web/app/components/plugins/marketplace/home/assets/dify-updates-art.png and /dev/null differ
diff --git a/web/app/components/plugins/marketplace/home/banners.spec.ts b/web/app/components/plugins/marketplace/home/banners.spec.ts
index aa89b2d1e0a..6ec2db1928f 100644
--- a/web/app/components/plugins/marketplace/home/banners.spec.ts
+++ b/web/app/components/plugins/marketplace/home/banners.spec.ts
@@ -110,6 +110,7 @@ describe('fetchPluginBanners', () => {
blog_title: 'Dify v1.9 new launch',
subtitle: 'New Agent node support',
description: 'Build agent workflows with the new Agent node.',
+ cover_image: '/api/v1/banners/images/banners/blog-cover.png',
link: 'https://dify.ai/blog',
link_target_type: 'blog',
},
@@ -152,6 +153,12 @@ describe('fetchPluginBanners', () => {
})
}
+ const blog = banners[1]
+ expect(blog?.style_type).toBe('blog')
+ if (blog?.style_type === 'blog') {
+ expect(blog.content.cover_image).toBe('/api/v1/banners/images/banners/blog-cover.png')
+ }
+
const event = banners[2]
expect(event?.style_type).toBe('event')
if (event?.style_type === 'event') {
@@ -162,6 +169,48 @@ describe('fetchPluginBanners', () => {
}
})
+ it('keeps a blog banner when cover_image is missing or blank', async () => {
+ mockedListBanners.mockResolvedValue({
+ data: {
+ banners: [
+ {
+ id: 'blog-blank-cover',
+ style_type: 'blog',
+ title: 'Dify Updates',
+ sort: 0,
+ language: 'en',
+ content: {
+ blog_title: 'Dify v1.9 new launch',
+ link: 'https://dify.ai/blog',
+ link_target_type: 'blog',
+ cover_image: '',
+ },
+ },
+ {
+ id: 'blog-no-cover',
+ style_type: 'blog',
+ title: 'Product',
+ sort: 1,
+ language: 'en',
+ content: {
+ blog_title: 'Another post',
+ link: 'https://dify.ai/blog/another',
+ link_target_type: 'blog',
+ },
+ },
+ ],
+ },
+ })
+
+ const banners = await fetchPluginBanners('en-US')
+
+ expect(banners.map((banner) => banner.id)).toEqual(['blog-blank-cover', 'blog-no-cover'])
+ for (const banner of banners) {
+ expect(banner.style_type).toBe('blog')
+ if (banner.style_type === 'blog') expect(banner.content.cover_image).toBeUndefined()
+ }
+ })
+
it('drops malformed banners and returns no placeholders for an empty response', async () => {
mockedListBanners
.mockResolvedValueOnce({
diff --git a/web/app/components/plugins/marketplace/home/banners.ts b/web/app/components/plugins/marketplace/home/banners.ts
index c604e7b0d41..c1fa59f8148 100644
--- a/web/app/components/plugins/marketplace/home/banners.ts
+++ b/web/app/components/plugins/marketplace/home/banners.ts
@@ -75,6 +75,7 @@ const blogContentSchema = z.object({
blog_title: z.string().min(1),
subtitle: lenientOptionalString,
description: lenientOptionalString,
+ cover_image: lenientNonEmptyString,
link: z.string().min(1),
link_target_type: z.enum(['blog', 'github']),
})
diff --git a/web/app/components/plugins/marketplace/home/home-trending-slides.tsx b/web/app/components/plugins/marketplace/home/home-trending-slides.tsx
index aa898514064..95cdfff3674 100644
--- a/web/app/components/plugins/marketplace/home/home-trending-slides.tsx
+++ b/web/app/components/plugins/marketplace/home/home-trending-slides.tsx
@@ -31,7 +31,6 @@ import MarketplaceDetailDialog from '../detail-dialog'
import TemplateDetailDialog from '../templates/template-detail-dialog'
import { getPluginLinkInMarketplace, getTemplateLinkInMarketplace } from '../utils'
import background from './assets/background.webp'
-import difyUpdatesArt from './assets/dify-updates-art.png'
import {
EMBEDDED_MOBILE_BANNER_MEDIA,
MARKETPLACE_MOBILE_BANNER_MEDIA,
@@ -556,6 +555,7 @@ function BlogBannerSlide({
const href = sanitizeMarketplaceHref(banner.content.link)
if (!href) return null
const opensInNewTab = /^https?:\/\//.test(href)
+ const coverSrc = getMarketplaceAssetURL(banner.content.cover_image)
return (
<Link
@@ -640,18 +640,20 @@ function BlogBannerSlide({
</div>
</div>
</div>
- <img
- src={difyUpdatesArt.src}
- width={400}
- height={200}
- alt=""
- aria-hidden
- className={cn(
- styles.updatesArt,
- isMarketplacePlatform && styles.stackedVisual,
- 'h-[200px] shrink-0 rounded-2xl object-cover object-left',
- )}
- />
+ {coverSrc ? (
+ <img
+ src={coverSrc}
+ width={400}
+ height={200}
+ alt=""
+ aria-hidden
+ className={cn(
+ styles.updatesArt,
+ isMarketplacePlatform && styles.stackedVisual,
+ 'h-[200px] shrink-0 rounded-2xl object-cover object-left',
+ )}
+ />
+ ) : null}
</Link>
)
}