first commit
This commit is contained in:
15
src/app/common/image-utils.ts
Normal file
15
src/app/common/image-utils.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { config } from "../../../config";
|
||||
|
||||
/**
|
||||
* Proxies all non-localhost images to make them load faster.
|
||||
*
|
||||
* @param originalUrl the original image url
|
||||
* @returns the new image url
|
||||
*/
|
||||
export function getImageUrl(originalUrl: string) {
|
||||
// Remove the prepending slash
|
||||
if (originalUrl.startsWith("/")) {
|
||||
originalUrl = originalUrl.substring(1);
|
||||
}
|
||||
return `${!config.siteUrl.includes("localhost") ? "https://img.fascinated.cc/upload/q_70/" : ""}${originalUrl}`;
|
||||
}
|
Reference in New Issue
Block a user