|
217 | 217 | */
|
218 | 218 | const imcgerImgUpload = {
|
219 | 219 | initialImage: function() {
|
| 220 | + const maxImageWidth = '{{ IUL_IMG_MAXWIDTH }}'; |
| 221 | + |
220 | 222 | // Return if no content is displayed
|
221 | 223 | if (!document.getElementsByClassName("content").length) {
|
222 | 224 | return;
|
|
226 | 228 | postbodyWidth = window.getComputedStyle(document.getElementsByClassName("content")[0]).width;
|
227 | 229 |
|
228 | 230 | postImageArray.forEach((image) => {
|
229 |
| - if (parseInt(image.naturalWidth) > parseInt(postbodyWidth)) { |
| 231 | + if (parseInt(image.naturalWidth) > parseInt(postbodyWidth) || parseInt(image.naturalWidth) > parseInt(maxImageWidth)) { |
230 | 232 | image.style.width = '100%';
|
231 |
| - image.style.maxWidth = '{{ IUL_IMG_MAXWIDTH }}'; |
| 233 | + image.style.maxWidth = maxImageWidth; |
232 | 234 | } else {
|
233 | 235 | image.style.width = 'auto';
|
234 | 236 | image.style.maxWidth = 'none';
|
|
242 | 244 | let postImageArray = document.querySelectorAll(".content img.postimage");
|
243 | 245 | postImageArray.forEach((image) => {
|
244 | 246 | image.onload = (event) => {
|
245 |
| - let postbodyWidth = window.getComputedStyle(document.getElementsByClassName("content")[0]).width; |
246 |
| - if (parseInt(image.naturalWidth) > parseInt(postbodyWidth)) { |
| 247 | + const maxImageWidth = '{{ IUL_IMG_MAXWIDTH }}'; |
| 248 | + let postbodyWidth = window.getComputedStyle(document.getElementsByClassName("content")[0]).width; |
| 249 | + |
| 250 | + if (parseInt(image.naturalWidth) > parseInt(postbodyWidth) || parseInt(image.naturalWidth) > parseInt(maxImageWidth)) { |
247 | 251 | image.style.width = '100%';
|
248 |
| - image.style.maxWidth = '{{ IUL_IMG_MAXWIDTH }}'; |
| 252 | + image.style.maxWidth = maxImageWidth; |
249 | 253 | } else {
|
250 | 254 | image.style.width = 'auto';
|
251 | 255 | image.style.maxWidth = 'none';
|
|
0 commit comments