Wedge

Public area => The Pub => Features => Topic started by: Arantor on March 8th, 2012, 03:56 PM

Title: Image resizing for non-uploads
Post by: Arantor on March 8th, 2012, 03:56 PM
Right now we have the ability to limit the image size of images posted via the img tag, to ensure they're not made huge.

E.g. if you try and post a massive photo but the settings say 150x150, you get a 150x150 size shown (though it doesn't actually resize/thumbnail the image, it just shows it at that size)

What I'm wondering is whether it might not be a bad idea to indicate that the picture isn't full size in those cases and have it automatically link back to the full size image - or even make use of Zoomedia to do that?
Title: Re: Image resizing for non-uploads
Post by: Nao on March 8th, 2012, 04:02 PM
We sure could... Actually I thought it already had this "click img" system...? Wasn't it in theme.js or somewhere?
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 8th, 2012, 04:06 PM
I just tried it and nothing happened that I could see, anyway... but I did it quickly, didn't check for errors, so it's entirely possible there is something already.
Title: Re: Image resizing for non-uploads
Post by: Nao on March 8th, 2012, 04:21 PM
Just seems so logical to me... Such a no-brainer...
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 8th, 2012, 04:22 PM
I would also note there are several SMF mods centered around doing the exact same thing with Highslide etc. so it would be good for us to do something similar in the core using the facilities you already made ;)
Title: Re: Image resizing for non-uploads
Post by: Nao on March 8th, 2012, 05:10 PM
Yeah. The problem with highslide is the license agreement.
Zoomedia emulates its feature set pretty well but it still needs some work.
Title: Re: Image resizing for non-uploads
Post by: spoogs on March 8th, 2012, 05:25 PM
I like the idea here as well... usually when images get resized they seem all blurry to me so anything that can expand to full-size is a plus to me
Title: Re: Image resizing for non-uploads
Post by: Aaron on March 8th, 2012, 11:46 PM
Quote from Nao on March 8th, 2012, 04:02 PM
We sure could... Actually I thought it already had this "click img" system...? Wasn't it in theme.js or somewhere?
I know I sneaked that into the 2.0 RC3 release a long time ago. Assuming you kept it whilst rewriting the lot to use jQuery, of course.

Replacing it with Zoomedia sounds like a good idea to me.
Title: Re: Image resizing for non-uploads
Post by: Nao on March 9th, 2012, 06:51 PM
This is definitely the code in theme.js, as modified for jQuery in Wedge:

Code: [Select]
// Toggles the element height and width styles of an image.
$('img.resized').css('cursor', 'pointer').click(function () {
this.style.width = this.style.height = (this.style.width == 'auto' ? null : 'auto');
});
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 10th, 2012, 01:18 PM
Hmm, in my test I noticed the .resized was added but clicking on the image did nothing, nor was it with a different cursor.

Would be nice to have Zoomedia on it though, for that extra bit of polish.
Title: Re: Image resizing for non-uploads
Post by: Nao on March 10th, 2012, 08:24 PM
Dunno. Anyone?
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 13th, 2012, 11:51 AM
Instead of worrying about whether it's broken or not, heh, I'm not exactly familiar with Zoomedia. What would I have to do to apply it to something?
Title: Re: Image resizing for non-uploads
Post by: Nao on March 14th, 2012, 10:51 AM
I'm afraid I don't remember... :lol:

It's all in AeMe. I'm sure we can cook up a version that works outside of it. (Well, technically it does, for picture embeds. I just don't remember where I'm doing the add_js stuff, ahah...)

No, seriously, Zoomedia was a nightmare to develop. It was done faster than many of the 'nightmares' I worked on, but it was enough of a hassle to encourage me to just leave it be instead of working on adding support for slideshows and video embedding.
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 14th, 2012, 01:17 PM
Well, if it were expected to be used generally, it might be a candidate for inclusion into script.js, then it's just a matter of calling it?
Title: Re: Image resizing for non-uploads
Post by: Nao on March 14th, 2012, 03:21 PM
Used generally = on every page...
If we use it only for resized attachments, then it's not every page. How many topics does Wedge.org have with a selection of screenshots and other items that would require resizing...? Not many.
Considering zoomedia.js is half the size of sbox.js, that would mean adding at least one kilobyte to the script file, for a feature that's not used everywhere, unlike our select boxes...
So, I would recommend against it.
An extra hit for every page that has a resized image is perfectly acceptable, especially considering caching, and the fact that the image itself already represents an extra hit... ;)
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 14th, 2012, 03:28 PM
I suppose that provided we perform the injection of zoomedia.js in place of the current code (i.e. doing the inclusion once we hit such an image) we would retain that benefit...
Title: Re: Image resizing for non-uploads
Post by: Nao on March 14th, 2012, 04:12 PM
That's exactly what AeMe does when it embeds an item -- but it makes me think, we have to do the change in the database, don't we...? Because it's in the img bbcode... The PHP code... Oh my... I hate that :P
Title: Re: Image resizing for non-uploads
Post by: Arantor on March 14th, 2012, 04:25 PM
Oh, yes, yes it is. That's why I asked what it would take to make it work because I'll sit and do it for you ;) I just don't know enough (anything?) about Zoomedia's internals and figured you'd be able to point me in the right direction.
Title: Re: Image resizing for non-uploads
Post by: Nao on March 14th, 2012, 04:40 PM
Hmmm... Basically, it would take this to work:

Code: [Select]
global $context;

loadSource('media/Aeva-Subs-Vital');
$context['header'] .= '
<link rel="stylesheet" href="' . add_css_file('zoom') . '" media="screen">' . aeva_initZoom(false);

The false is for autosize, which is currently not implemented. There's an additional param where you an set the outline type (array('outline' => 'black') for instance), or an expand delay ('expand' in milliseconds).

I think it should work... But please check first :)