This commit is contained in:
parent
cfb21e7dcb
commit
40f038bfb9
1 changed files with 36 additions and 30 deletions
|
@ -1,33 +1,39 @@
|
||||||
for (const item of document.getElementsByTagName("img")) {
|
window.addEventListener("load", () => main());
|
||||||
// Check if we may need to resize the image
|
|
||||||
const possible_piece = item.alt.split(/\s?\|\s?/);
|
const main = () => {
|
||||||
if (possible_piece.length > 1) {
|
for (const item of document.getElementsByTagName("img")) {
|
||||||
// Check if 1 or 2 dimension(s) is provided
|
// Check if we may need to resize the image
|
||||||
// Then, check if syntax is correct
|
const possible_piece = item.alt.split(/\s?\|\s?/);
|
||||||
//
|
if (possible_piece.length > 1) {
|
||||||
// If everything is good, assign the width and/or the height
|
// Check if 1 or 2 dimension(s) is provided
|
||||||
// to the image and remove the resize data from the alt text
|
// Then, check if syntax is correct
|
||||||
const last_possible_piece =
|
//
|
||||||
possible_piece[possible_piece.length - 1].trim();
|
// If everything is good, assign the width and/or the height
|
||||||
// Remove the resize data from the list
|
// to the image and remove the resize data from the alt text
|
||||||
possible_piece.pop();
|
const last_possible_piece =
|
||||||
if (last_possible_piece.includes("x")) {
|
possible_piece[possible_piece.length - 1].trim();
|
||||||
const verif = last_possible_piece.split(/\d+/);
|
// Remove the resize data from the list
|
||||||
if (
|
possible_piece.pop();
|
||||||
verif.length == 3 &&
|
if (last_possible_piece.includes("x")) {
|
||||||
verif[0] == "" &&
|
const verif = last_possible_piece.split(/\d+/);
|
||||||
verif[1] == "x" &&
|
if (
|
||||||
verif[2] == ""
|
verif.length == 3 &&
|
||||||
) {
|
verif[0] == "" &&
|
||||||
[item.width, item.height] = last_possible_piece.split("x");
|
verif[1] == "x" &&
|
||||||
item.alt = possible_piece.join("");
|
verif[2] == ""
|
||||||
}
|
) {
|
||||||
} else {
|
[w, h] = last_possible_piece.split("x");
|
||||||
const verif = last_possible_piece.split(/\d+/);
|
item.width = w;
|
||||||
if (verif.length == 2 && verif[0] == "" && verif[1] == "") {
|
item.height = h;
|
||||||
item.width = last_possible_piece;
|
item.alt = possible_piece.join("");
|
||||||
item.alt = possible_piece.join("");
|
}
|
||||||
|
} else {
|
||||||
|
const verif = last_possible_piece.split(/\d+/);
|
||||||
|
if (verif.length == 2 && verif[0] == "" && verif[1] == "") {
|
||||||
|
item.width = last_possible_piece;
|
||||||
|
item.alt = possible_piece.join("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in a new issue