Skip to content

Commit

Permalink
fix: path upload plugin to fix URL issue (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Jul 5, 2024
1 parent 9d70eae commit 45a08a4
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 31 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"compile:lib": "npx tsc -p lib/tsconfig.json",
"strapi": "strapi",
"publish:lib": "scripts/publish-lib.sh",
"prepublishOnly": "echo '❌ ERROR: The lib should be published from \"lib\" directory. Read README for more information.' && exit 99"
"prepublishOnly": "echo '❌ ERROR: The lib should be published from \"lib\" directory. Read README for more information.' && exit 99",
"postinstall": "patch-package"
},
"dependencies": {
"@strapi/plugin-documentation": "4.13.3",
Expand All @@ -35,6 +36,7 @@
"@strapi/strapi": "4.13.3",
"better-sqlite3": "8.5.0",
"openapi-typescript": "^6.7.5",
"patch-package": "^8.0.0",
"pg": "^8.11.3",
"rimraf": "^5.0.5"
},
Expand Down
16 changes: 16 additions & 0 deletions patches/@strapi+plugin-upload+4.13.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/@strapi/plugin-upload/admin/src/components/AssetCard/ImageAssetCard.js b/node_modules/@strapi/plugin-upload/admin/src/components/AssetCard/ImageAssetCard.js
index a390077..19722a1 100644
--- a/node_modules/@strapi/plugin-upload/admin/src/components/AssetCard/ImageAssetCard.js
+++ b/node_modules/@strapi/plugin-upload/admin/src/components/AssetCard/ImageAssetCard.js
@@ -10,7 +10,10 @@ import { AssetCardBase } from './AssetCardBase';
export const ImageAssetCard = ({ height, width, thumbnail, size, alt, ...props }) => {
// Prevents the browser from caching the URL for all sizes and allow react-query to make a smooth update
// instead of a full refresh
- const urlWithCacheBusting = appendSearchParamsToUrl({ url: thumbnail, params: { updatedAt: props.updatedAt } });
+ const urlWithCacheBusting = appendSearchParamsToUrl({
+ url: thumbnail.startsWith('/') ? location.origin + thumbnail : thumbnail,
+ params: { updatedAt: props.updatedAt }
+ });

return (
<AssetCardBase {...props} subtitle={height && width && ` - ${width}✕${height}`} variant="Image">
Loading

0 comments on commit 45a08a4

Please sign in to comment.