XF 2.1 How to resize images hosted elsewhere?

We currently have an issue where some users are linking to images on Imgur in their statuses and these images are monstrously huge. Is there a way to automatically resize how they're displayed on the forum?
 
above code is pretty useful but would not reduce the download size of the hotlinked image :D

there are server based solutions available for this. cloudflare has a paid product (mirage and polish). or if you are self managing your server, you can look into implementing something like


Another cool thing about Imgur... They actually have multiple size versions of the images. So if a user posts something like: https://i.imgur.com/Fj0iyPL.png, you can basically just rename the file to https://i.imgur.com/Fj0iyPLh.png (added h at the end of file name). you can also replace png with jpg to further reduce the file size. i imagine one can create a regex powered file and replace command that could potentially rename all imgur image links to smaller sized versions. that part is out of my expertise.
 
I am using this and it works great on 2.2.

CSS:
.bbImage {
    max-width: 400px;
    max-height: 600px;
    object-fit: contain;
    border: solid 1px #bbb;
    padding: 4px;

}

do make sure you are modifying the extra.less file in the style you are checking on. you can have different files for different themes.
 
worked like a charm. Thank you.
I believe that will affect all images everywhere whether attached or hot linked. I may be wrong but I would check.

The foolproof way for hotlinked images (eg from Imgur) is probably only feasible if you do it per image.

So you need to check the url of the image and put this in extra.less

Code:
[data-url="https://URL_OF_IMAGE.jpg"]
{width:200px;height:100px}
 
Last edited:
Top Bottom