Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How can I have images resize + open in a new tab?
md82
New
Hi, is there a way I could have my forum images resize to fit the width of my page, but open in a new tab rather then going full size inside of the window? I ask this because I'm embedding my forum in another webpage that has limited width. I've tried multiple addons but they have not worked for this particular issue.
Thanks in advance.
0
Comments
I recall something like this mentioned in the forum. You would need to do some searching this forum. if you come out with the solution thread post it here.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I posted my code to accomplish this here:
http://vanillaforums.org/discussion/comment/170032
I was able to get the maximagesize addon working by removing the vanilla resizer in the global.js.
Though if you are logged in as admin it doesnt seem to work as reliable. It seems every other time the images load full resolution. Is there javascript for admin users I can edit?
Looks like 50s has the code mostly done that could be put into my plugin, I don't really have the time to do it currently. You would just have to override the click behavior on the text the plugin adds to open in a new window instead of unresizing.
Yes you have to disable the built in image resizer in global.js, I should probably add that to the plugins page. There is only one javascript file for admins and normal users. I haven't experienced what you're seeing, maybe the global.js change is being cached or something? It works 100% of the time as admin for myself.
Yes that appeared to be an anomaly. Now I've noticed that in chrome it doesn't function that well, but in firefox its 100% working for users and admins.
I tried it with v2.1a33 and it opens two tabs/windows instead of one. I took a wild guess and have removed the
jQuery(window).load(function() { LinkifyImages(); });
part. Now it seems to work correctly. Basically I would prefer to use Vanilla's code, but unfortunately it is broken in IE8.As for the original question, just change
img.wrap('<a href="'+$(img).attr('src')+'"></a>');
line toimg.wrap('<a href="'+$(img).attr('src')+'" target="_blank"></a>');
in global.js.What do you mean by it doesn't function well? Chrome is what I use day to day and haven't experienced issues.
I mean the images resize in firefox, and in chrome it leaves them full resolution.
Are you sure it's not a caching issue? Are there errors in the javascript console etc, I'm using chrome for everything as mentioned and it works fine for me so I can't really see where you are having issues.
Ok so just I went from the "MaxImageSize" addon that wasnt working for me to the "ImageResizer" and thats working for me in both browsers..
Now because I'm using the vanilla "embed" addon too, is there a edit to the js I could do to have it open in a new tab instead of resize in the container?
Thanks for the help
Not currently, as I said initially you would have to modify the javascript to override the click call on a href to open the image in a new window instead of unresizing.
I cannot help you at all on MaxImageSize plugin I only wrote ImageResizer.