![]() |
Replace large images in posts with links to the images
No longer supported by the author.
|
First post reserved for notes, etc as I know some of you surf with the hacks collapsed.
|
Excellent! Thanks for the hack!
|
Has vb.org got something weird in it that turns double spaces into tabs? My beautifully indented code comes out all strange.
|
Not sure but if you put the intructions in a txt file and zip up both the instructions and the php file, it will aleviate that.
Will also make it easier for end users as they now have a neatly packaged hack stored locally. ;) |
One question what about un-registered users? Do they see the link or a large image?
|
the JACKPOT hack will be when someone makes a "resize if >500px hack" or something
good try tho. |
Quote:
The JavaScript will fire, but the script web service that I have that services that JavaScript won't change the post when a guest calls it. I should note that in nearly all cases this means they see the link... because the moment a post is posted the author is returned to it, and it is they that trigger the conversion from [url] to [img]. So anyone who manages to see the post is usually just going to see a link. The exception to the above are historical posts, which require a registered user to go view for the conversion to occur. |
Quote:
Yes CSS and HTML can be written to re-format the size, create scroll bars on it or resize the image dimensions in JavaScript. However every user still ends up having to download that 1.7mb image for the CSS and/JavaScript to resize it. My idea of a jackpot hack for oversized images is to not have those users download the images in the first place. Of giving them the choice to download it. And as a result retain the perception that my forum is fast. This means converting inline images to links, which my hack does. So I guess whether you like this hack or not depends on point of view, whether you agree with my design decision that not having users download large images unawares is important, or whether you feel that the layout of the page is more important than the download experience for users. |
Quote:
|
Screenshots for those who need such things now attached.
I've used this image as an example: http://miam-miam.viabloga.com/images...ufs%20durs.jpg Because it's 1024 pixels wide, it gets replaced by a link after the first view. |
Would be great if it does what promiced :) I've editted an already placed oversized image that whas reduced with the 3.xx BIMG tags but it did not turn into a link. Maybe it will only work with new posted images.
|
Quote:
The only thing it won't work with is pure HTML. But no-one allows users to post HTML because of security risks, right? Anyhow, so long as you have a DOM capable browser that supports XmlHttp and either element.parentElement (IE6) or element.parentNode (Mozilla and the others, this is the W3C implementation)... then it will call the script. Oh, but if you have edited your templates from the vb default and nuked the following from the postbit templates, then you will prevent the hack from working: Code:
<div id="post_message_$post[postid]">$post[message]</div> |
And if you're sure it's not working, just say and I'll add some trace/debug stuff to it so that you can optionally see it working before you switch it to run silently.
|
Quote:
With the hack installed you don't need to edit anything :D You just view them. Order of events:
So you don't need to edit anything. Just CTRL+F5 to ensure your browser has the latest version of vbulletin_global.js, and then view the thread. Once viewed, click CTRL+F5 again to refresh the page and the image should be gone. |
I had to refresh the page a few times to see the link without the pic. Not sure what that was, but it seems to work now. Great hack.
|
Refreshed several times, logged in and logged out etc. but the image stays large. I've looked into the js and the url to trimOversizedImages.php is correct. I'll check the
Code:
<div id="post_message_$post[postid]">$post[message]</div> |
I'll add a debugging option for you... that way you can see what happens... via the wonder of JavaScript alerts ;)
It will be off by default, but you can enable and disable debugging and if enabled it will give you popup messages from the web service saying what happened. Give me 10 minutes for this :) |
I've added debugging capabilities, and updated the file to upload and the JavaScript to run.
Simply update by uploading the new .php file over the old one, and replace the JavaScript with the new version in the zip file. Debugging will give you JavaScript alerts whenever it does stuff, so you will be able to 'see' things happening. |
<a href="http://www.cyberty.nl/forums/showthread.php?t=8987" target="_blank">http://www.cyberty.nl/forums/showthread.php?t=8987</a> look at the size (should be 500 - 500 when conversion to link must work) ... it shows no alert, no reducing.
|
Quote:
If it's not in there, it certainly isn't going to convert any images to links. You can see at the end of my JavaScript file the hack in place: http://www.bowlie.com/forum/clientsc...tin_global.js? Did you upload the file once you had modified it? |
I see what went wrong, sorry :) I've uploaded the additional js file
|
Cool, I see it works now :)
I leave the "// HACK" bits in my JavaScript btw... this way when I upgrade I search my codebase for all instances of the word HACK and know which file changes I have to port over :) |
Now there's a javascript error: id is empty or no object
|
Quote:
You'd nuked the JS from your file again so I can't see whether there was an error with the installation. However I have gone over my code again, and there was one scenario that could cause the error you described, so I've put more error checking in my code to test attributes of objects before I call them. Download and install it again and let me know whether that fixes it. If it does not, please leave the code in place as I will very swiftly check your forums to see the error live and stand a better chance at tracing it. Cheers David K |
Tnx for the update buro9 the error is gone now. I'm very happy with this autolink/resize :)
|
Quote:
Updated the version number to reflet fixing the JavaScript |
I'm considering an audit trail for both visibility (seeing that it is working) and security (seeing who triggered which posts to be edited).
This would be in the form of a database table that simply logs:
This would allow you to create your own queries to determine:
It would be a SQL change (new table), but beyond that nothing out of the ordinary. |
Thanks, was looking for this!
|
Haven't installed yet, but from the screenshots it seems this is not a feature: could you please add a "[This picture is auto-linked because the original picture is too large]". Even better would be to have this in a legend-div, but I can easily whip that up myself :)
|
Quote:
I can add an edited message, either in the post itself (I'm loathed to do this as I'd rather not be inserting text when it may change the context of text within the post in any way) or in the editlog so that it appears at the foot as 'edited by', but I'd rather not do this as it then appears that someone is manually editing everyone's post and people can get uppity about that. Instead, I communicate it globally via an announcement in my "About A Board" forum, and by including image dimensions and what happens when images exceed it to my "Forum Rules". I think this is best as people don't complain about automatic processes that apply the rules universally, but do complain if they perceive that they are being manually edited by admins. That, and if I communicate it as a core rule, I can actually hope to educate them about what happens and why, and thus they may start to do things properly like resize the image and attach it if they really want people to see it, etc. All that said... if most of the people here want text inserted to reflect that a change was made, then I shall do so. There is always the other option though, that you simply look within trimOversizedImages.php and where I insert [/url] append whatever text you want just there. Cheers David K |
Quote:
No, no, you misunderstood! I really like this hack and will definitely use this when I finally upgrade my board to 3.5. What I meant was: the text insertion isn't a feature yet, hence the request. But I can see where you coming from, and maybe a global announcement is the better way to go. But thanks for the pointer where to put it if I still feel like doing it myself. Thanks again for this great hack, I share the sentiments on the other hacks that try to do the same thing. |
Hello,
this hack is great and is exactly what I was looking for ! But is there a way to make it vb3.0 compliant ? I suppose I will need to edit my "postbit_legacy" template to insert the postId in the Div, but which Div is concerned, and would it be enought to make it work ? |
Quote:
A very good point... the original templates never included an identifier, the new templates now include: [code] <!-- message --> <div id="post_message_$post[postid]">$post[message]</div> <!-- / message --> [code] So I should now be using post_message_POSTID as the div to search for. I'll update it now for you :) |
Oh no, misunderstanding. It does already search for post_message_POSTID. My instructions are crap, not my code :)
|
The key message is: If you are not using the original/default postbit templates, then you will need to double check that the post_message_$post[postid] DIV exists.
You can view the original version of the template, and DIFF against it to see which DIV should have this. All those who have installed against a default install will be fine. If you are not on a vb3.5 variant... then the code above WILL work all the way back to vb 2.x, but you need to insert the DIV yourself: FIND: Code:
$post[message] Code:
<div id="post_message_$post[postid]">$post[message]</div> |
Ok that's what I thought. I'm going to test it, and I'll keep you informed ;)
Thanks for your answear, David ! :) |
Does this make a call to the server 'every time' an image is viewed? If so wouldn't it be more efficient to make the call only when a user 'posts' an image, and if it's too big, either make it the url then or notify the poster to resize the image?
There was a hack for phpbb that did it that way :) |
When a large image is viewed, a call is made to the server, but as it is then replaced with a link, no more calls are made to the server as no large image is detected. So... only one call is made per large image.
|
If you have more than 1 image in a post and one is over the dimensions but the other is not, does it make a link for the both of them? ;)
|
All times are GMT. The time now is 04:06 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|