Skip to content

Conversation

@starry-osean
Copy link

What is this PR for?
This PR updates the
imageProcessor
service to support serving static assets located in theme-specific public folders (e.g., themes/my-theme/public/image.png).

Why is this needed?
Previously, the /images route only looked for assets in the root media/ and public/ directories. This prevented theme developers from including custom assets within their theme structure, causing 404 errors for theme-specific images.

How was this implemented?
Modified
packages/evershop/src/modules/cms/services/imageProcessor.ts
.
Added logic to dynamically scan the themes/ directory.
Included themes/<theme_name>/public/ paths in the asset search priority list.
How to test?
Create a theme directory: themes/test-theme/public/.
Place an image file there (e.g., test-image.png).
Access the image via the browser or API: /assets/test-image.png.
The image should load correctly instead of returning a 404 error.

@starry-osean
Copy link
Author

Hi,@treoden ! this PR updates the imageProcessor service to support serving static assets from theme-specific public folders (e.g. themes/my-theme/public/image.png).

Reason: previously /assets only checked root media/public, so theme-specific assets returned 404.
Scope: only extends search paths to include themes/<theme_name>/public, existing behavior remains unchanged.
Testing:
Created themes/test-theme/public/test-image.png
Accessed /assets/test-image.png and verified it’s served correctly.
Could you please help review this PR and let me know if anything needs to be adjusted? Thanks!

@treoden
Copy link
Collaborator

treoden commented Dec 17, 2025

Hi @starry-osean ,

I understand what you are trying to do. My point is:
We should not allow all existing path in the themes folders, we should only allow the one (the theme) that currently in use

You can use this function for getting the current active theme
import { getEnabledTheme } from '../../lib/util/getEnabledTheme.js';

Thanks

@starry-osean
Copy link
Author

你好@starry-osean

我明白你的意思。我的意思是: 我们不应该允许文件夹中所有已存在的路径themes,而应该只允许当前正在使用的路径(主题)。

您可以使用此函数获取当前活动主题。 import { getEnabledTheme } from '../../lib/util/getEnabledTheme.js';

谢谢

@treoden ,you're right! I misunderstood it before,but now I have corrected it. Please let me know if this matches what you had in mind or if you’d like any further adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants