update image thumb
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { AttachmentAPI } from "timi-web";
|
||||
|
||||
/**
|
||||
* 获取附件读取地址。
|
||||
*
|
||||
* @param id 附件 ID
|
||||
* @param thumbnailSize 缩略图尺寸,不传时返回原图地址
|
||||
*/
|
||||
export function getAttachmentReadURL(id: string, thumbnailSize?: number): string {
|
||||
const url = AttachmentAPI.getReadURL(id);
|
||||
if (thumbnailSize === undefined) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({
|
||||
thumbWidth: String(thumbnailSize),
|
||||
thumbHeight: String(thumbnailSize)
|
||||
});
|
||||
const separator = url.includes("?") ? "&" : "?";
|
||||
return `${url}${separator}${params.toString()}`;
|
||||
}
|
||||
Reference in New Issue
Block a user