Merge pull request 'Use the Site design logo as the favicon (site and admin)' (#11) from logo-favicon into main
Reviewed-on: #11
This commit is contained in:
commit
4b50067a4a
4 changed files with 27 additions and 3 deletions
|
|
@ -20,3 +20,14 @@ export function createPocketBase(authCookie?: string, url = pbUrl) {
|
|||
export function getFileUrl(collectionIdOrName: string, recordId: string, filename: string) {
|
||||
return `${pbUrl}/api/files/${collectionIdOrName}/${recordId}/${filename}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* A small version of an uploaded image: PocketBase makes thumbnails of media
|
||||
* files in the sizes listed on the field (`media.file` has 300x300, cropped
|
||||
* to fill). Other URLs (and SVGs, which PocketBase doesn't resize) are
|
||||
* returned as they are.
|
||||
*/
|
||||
export function thumbUrl(url: string, size: '300x300' | '1200x0' = '300x300') {
|
||||
if (!url.includes('/api/files/') || /\.svg(\?|$)/i.test(url)) return url;
|
||||
return `${url}${url.includes('?') ? '&' : '?'}thumb=${size}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue