MyBB Community Forums

Full Version: Simple Image Upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
(2013-02-10, 10:04 AM)KingCupid Wrote: [ -> ]What is dev key? where can i get one? Is that free?

https://imgur.com/register/api_anon
martec...how to insert into post?
(2013-02-10, 10:04 AM)KingCupid Wrote: [ -> ]Everything working file. Upload done smoothly but how to insert it post? No option for inserting into post? Please help..I badly need this Imgur upload feature. Thanx in advance.

change image.php with code below

<html>
<head>
<title>Image Upload</title>
</head>
</html>
<h1>Upload to imgur :</h1>
<br /><br />
<button onclick="document.querySelector('input').click()">Select file...</button>
<input style="visibility: collapse; width: 0px;" type="file" onchange="upload(this.files[0])">

<script>
    window.ondragover = function(e) {e.preventDefault()}
    window.ondrop = function(e) {e.preventDefault(); upload(e.dataTransfer.files[0]); }
    function upload(file) {

        /* Is the file an image? */
        if (!file || !file.type.match(/image.*/)) return;

        /* It is! */
        document.body.className = "uploading";

        /* Lets build a FormData object*/
        var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
        fd.append("image", file); // Append the file
        fd.append("key", "your dev key"); // Get your own key http://api.imgur.com/
        var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com
        xhr.open("POST", "http://api.imgur.com/2/upload.json"); // Boooom!
        xhr.onload = function() {
            // Big win!
            document.querySelector("#link").innerHTML = '[img]' + JSON.parse(xhr.responseText).upload.links.original + '[/img]';
			document.querySelector("#img").innerHTML = '<img src="' + JSON.parse(xhr.responseText).upload.links.original + '" style="max-width:280px;max-height:280px;" border="0" />';
            document.body.className = "uploaded";
var code = '[img]' + JSON.parse(xhr.responseText).upload.links.original + '[/img]';
			var editor = eval('opener.' + 'clickableEditor');
			editor.performInsert(code);
javascript:window.close()
        }
        // Ok, I don't handle the errors. An exercice for the reader.

        /* And now, we send the formdata */
        xhr.send(fd);
    }
</script>

<!-- Bla bla bla stuff ... -->

<style>
    body {text-align: center; padding-top: 10px;}
    h1 { font-size: 18px; font-weight: bold; }
    div { }
    #link, p , div {display: none}
    div {display: inline-block;}
    .uploading div {display: none}
    .uploaded div {display: none}
    .uploading p {display: inline}
    .uploaded #link {display: inline}
	.uploaded #img {display: inline}
    em {position: absolute; bottom: 0; right: 0}
</style>
<br /><br />
<p>Uploading...</p>
<a id="link"></a>
<br /><br />
<a id="img"></a>
Working Perfectly...Thax Buddy.....!!!!
(2012-12-25, 03:51 AM)Wildcard Wrote: [ -> ]This does not require a plugin.

All this plugin does is add the following script to every page:





<script type='text/javascript' src='http://mod.postimage.org/mybb-english.js' charset='utf-8'></script>

Simply inserting this code into the template Show Thread -> showthread will accomplish exactly the same thing.







I try but i don't know where to put it exactly ? it's works only with quick answer but not in new thread etc...
thanks,
Or copy the script ??

<script type="text/javascript" src="http://mod.postimage.org/website-french.js" charset="utf-8"></script>

<html>
<head>
<title>{$lang->newthread_in}</title>
{$headerinclude}
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/post.js?ver=1800"></script>
</head>
<body>
{$header}
{$preview}
{$thread_errors}
{$attacherror}
{$moderation_notice}
<form action="newthread.php?fid={$fid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->post_new_thread}</strong></td>
</tr>
{$loginbox}
<tr>
<td class="trow2" width="20%"><strong>{$lang->thread_subject}</strong></td>
<td class="trow2">{$prefixselect}<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
{$posticons}
<tr>
<td class="trow2" valign="top"><strong>{$lang->your_message}</strong>{$smilieinserter}</td>
<td class="trow2">
<textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
{$codebuttons}
{$multiquote_external}
</td>
</tr>
<tr>
<td class="trow1" valign="top"><strong>{$lang->post_options}</strong></td>
<td class="trow1"><span class="smalltext">
<label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked['signature']} /> {$lang->options_sig}</label>
{$disablesmilies}</span></td>
</tr>
{$modoptions}
{$subscriptionmethod}
{$pollbox}
{$captcha}
</table>
{$attachbox}
<br />
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div>
<input type="hidden" name="action" value="do_newthread" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
<input type="hidden" name="tid" value="{$tid}" />
{$editdraftpid}
</form>	
{$forumrules}	
{$footer}
<script type="text/javascript">
	$(".author_avatar img").error(function () {
		$(this).unbind("error").closest('.author_avatar').remove();
	});
</script>
</body>
</html>
hi .... does not seem to work with mybb 1.8.9

i would love if could work with imgbb (paste, drag+drop, point url, upload, external, etc)

EDIT: nevermind .. it was me that i did not upload plugin properly to forum (need to decompress before instead drag from 7zip)

... but now i have another issue ... the image i pasted seems cropped , i cannot turn fullsize
Look here => https://postimage.io/site-plugins/mybb.php

But be sure that this is an external script which can be changed by script hoster at everytime. Installing it could be a security risk.
Pages: 1 2 3