Skip to content

Commit

Permalink
PRO-6835: Determine Best AssetUrl is in easy mode with the new build …
Browse files Browse the repository at this point in the history
…system (#4814)
  • Loading branch information
myovchev authored Nov 23, 2024
1 parent e8c1c9e commit e05027b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Fixes

* Fixes broken widget preview URL when the image is overridden (module improve) and external build module is registered.

## 4.10.0 (2024-11-20)

### Fixes
Expand Down
7 changes: 6 additions & 1 deletion modules/@apostrophecms/module/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,8 @@ module.exports = {
let urlOption = self.options[`${name}Url`];
const imageOption = self.options[`${name}Image`];
if (!urlOption) {
if (imageOption) {
// Webpack and the legacy asset pipeline
if (imageOption && !self.apos.asset.hasBuildModule()) {
const chain = [ ...self.__meta.chain ].reverse();
for (const entry of chain) {
const path = `${entry.dirname}/public/${name}.${imageOption}`;
Expand All @@ -828,6 +829,10 @@ module.exports = {
}
}
}
// The new external module asset pipeline
if (imageOption && self.apos.asset.hasBuildModule()) {
urlOption = `/modules/${self.__meta.name}/${name}.${imageOption}`;
}
}
if (urlOption && urlOption.startsWith('/modules')) {
urlOption = self.apos.asset.url(urlOption);
Expand Down

0 comments on commit e05027b

Please sign in to comment.