| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/@nuxt/image/dist/runtime/providers/ |
Upload File : |
import {joinURL, encodePath} from "ufo";
import defu from "defu";
import {createOperationsGenerator} from "~image";
const convertHextoRGBFormat = (value) => value.startsWith("#") ? value.replace("#", "rgb_") : value;
const removePathExtension = (value) => value.replace(/\.[^/.]+$/, "");
const operationsGenerator = createOperationsGenerator({
keyMap: {
fit: "c",
width: "w",
height: "h",
format: "f",
quality: "q",
background: "b",
rotate: "a",
roundCorner: "r",
gravity: "g",
effect: "e",
color: "co",
flags: "fl",
dpr: "dpr",
opacity: "o",
overlay: "l",
underlay: "u",
transformation: "t",
zoom: "z",
colorSpace: "cs",
customFunc: "fn",
density: "dpi"
},
valueMap: {
fit: {
fill: "fill",
inside: "pad",
outside: "lpad",
cover: "fit",
contain: "scale",
minCover: "mfit",
minInside: "mpad",
thumbnail: "thumb",
cropping: "crop",
coverLimit: "limit"
},
format: {
jpeg: "jpg"
},
background(value) {
return convertHextoRGBFormat(value);
},
color(value) {
return convertHextoRGBFormat(value);
},
gravity: {
auto: "auto",
subject: "auto:subject",
face: "face",
sink: "sink",
faceCenter: "face:center",
multipleFaces: "faces",
multipleFacesCenter: "faces:center",
north: "north",
northEast: "north_east",
northWest: "north_west",
west: "west",
southWest: "south_west",
south: "south",
southEast: "south_east",
east: "east",
center: "center"
}
},
joinWith: ",",
formatter: (key, value) => `${key}_${value}`
});
const defaultModifiers = {
format: "auto",
quality: "auto"
};
export const getImage = (src, {modifiers = {}, baseURL = "/"} = {}) => {
const mergeModifiers = defu(modifiers, defaultModifiers);
const operations = operationsGenerator(mergeModifiers);
const remoteFolderMapping = baseURL.match(/\/image\/upload\/(.*)/);
if (remoteFolderMapping?.length >= 1) {
const remoteFolder = remoteFolderMapping[1];
const baseURLWithoutRemoteFolder = baseURL.replace(remoteFolder, "");
return {
url: joinURL(baseURLWithoutRemoteFolder, operations, remoteFolder, src)
};
} else if (/\/image\/fetch\/?/.test(baseURL)) {
src = encodePath(src);
} else {
src = removePathExtension(src);
}
return {
url: joinURL(baseURL, operations, src)
};
};