News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Simple Image Upload

Started by Sium, March 02, 2009, 12:01:05 PM

Previous topic - Next topic

jsx

I wonder how to change the type of inserted link from this modification? A link to the thumbnail image is currently being inserted, and I would like to change it to a direct link. Can it be changed? 8)


Adrek

According to JS file, uploaded image result should be hotlinked image file, but since that does not happen I think that they (imgbb.com) changed how script works on their end and hotlinking is disabled.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

jsx

I understand. Thank you for the clarification. :)

cornflakes

Quote from: Kindred on January 22, 2018, 06:03:09 PM
Well, given that the mod authors never repsonded to my concern, here or on their own site...

the index.template.php code add should be corrected

this is what the code should look like after adjustment...


if ($context['current_action'] == 'post') {
  echo '
    <script type="text/javascript" async src="Themes/default/scripts/imgbb.js" charset="utf-8"></script>';
  }
  echo '
</body></html>';


this way, the image javascript is ONLY loaded on the post page - not on every page load.


Hi!  I'm new.  So this corrected code you wrote down....am I able to edit this or were you just writing down what it should be for the author of this mod?    If it's editable by the user (me), I'd like to change it to yours so it doesn't do what you said (only loads on the post page not on every page load).

Thanks

Kindred

After you install the mod you can manually change the code to match what I wrote
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

cornflakes

Quote from: Kindred on May 27, 2020, 12:58:56 AM
After you install the mod you can manually change the code to match what I wrote

Ok thanks!

jsx

Does anyone know how to replace the dot before "Add image to post" in the code with an icon for this service?





imgbb.js:

if(imgbb_lang=="en"){imgbb_lang="";}else if(imgbb_lang.indexOf(".")===-1){imgbb_lang+=".";}if(window.location.hash){var imgbb_text;var imgbb_hash;if(window.name.indexOf("imgbb_")===-1){imgbb_text=window.name;imgbb_hash=window.location.hash.substring(1).split("_");}else{imgbb_text=window.location.hash.substring(1);imgbb_hash=window.name.split("_");}if(imgbb_text!="" && imgbb_hash.length>1){if(imgbb_hash[0]=="imgbb"){var imgbb_id=imgbb_hash[1];imgbb_text=decodeURIComponent(imgbb_text);if(imgbb_text.length>20){if(opener!=null && !opener.closed){var imgbb_area=opener.document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i++){if(i==imgbb_id){var editor=false;if(typeof opener.smf_editorArray==='object'){for(var A in opener.smf_editorArray){if(opener.smf_editorArray[A].opt.sUniqueId==imgbb_area[i].id){opener.smf_editorArray[A].insertText(opener.smf_editorArray[A].getText()+imgbb_text,true);editor=true;}}}if(editor==false){imgbb_area[i].value=imgbb_area[i].value+imgbb_text;}opener.focus();window.close();}}}}window.location.replace("//" + imgbb_lang + "imgbb.com/upload?mode=code&url=" + encodeURIComponent(document.location.href));}}}function imgbb_insert(){var imgbb_area=document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i++){if(imgbb_area[i].name && !imgbb_skip_textarea.test(imgbb_area[i].name)){var attr=imgbb_area[i].getAttribute('data-imgbb');if(attr!="true"){var imgbb_div=document.createElement('div');imgbb_div.setAttribute('class',"imgbb");var imgbb_a=document.createElement('a');imgbb_a.innerHTML=imgbb_add_text;imgbb_a.href="javascript:imgbb_upload("+i+");";var imgbb_bullet=document.createElement('span');imgbb_bullet.setAttribute('class',"imgbb_bullet");imgbb_bullet.innerHTML="&#160;&#8226;&#160;";imgbb_div.appendChild(imgbb_bullet);imgbb_div.appendChild(imgbb_a);imgbb_area[i].setAttribute('data-imgbb',"true");if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].parentNode.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].parentNode.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.parentNode.appendChild(imgbb_div);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && imgbb_area[i].nextElementSibling.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else{if(imgbb_area[i].nextSibling.nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else if(imgbb_area[i].nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else{imgbb_area[i].parentNode.appendChild(imgbb_div);}}}}}}function imgbb_upload(areaid){window.open("//" + imgbb_lang + "imgbb.com/upload?mode=smf&url=" + encodeURIComponent(document.location.href),"imgbb_" + areaid,"resizable=yes,width=720,height=550");return void(0);}if(typeof(window.addEventListener)=='function'){window.addEventListener('DOMContentLoaded',imgbb_insert,false);window.addEventListener('load',imgbb_insert,false);}else if(typeof(window.attachEvent)=='function'){window.attachEvent('onload',imgbb_insert);}else{if(window.onload!=null){var old_onload=window.onload;window.onload=function(e){old_onload(e);imgbb_insert();};}else{window.onload=imgbb_insert;}}for(var i=1;i<12;i+=2){setTimeout("imgbb_insert()",i*1000);}imgbb_insert();}

pikeman

Does not work on SMF 2.1, is there a solution?

pikeman

Insert the code into index.template.php before </head> and the mode will work.

<script async type="text/javascript" src="//mod.imgbb.com/website-hotlink.js" charset="utf-8"></script>

rapalero

Hi. The https://custom.simplemachines.org/index.php?mod=1669 mod now shows me only square thumbnails in the new images uploaded by users and https://imgbb.com/mod does not generate the mod, the website tells me "request denied".  Any ideas or other simple alternative for users? Greetings and thanks.

Metaltype

Quote from: pikeman on February 17, 2022, 10:43:20 AMDoes not work on SMF 2.1, is there a solution?
Yes, me too. This mod was very popular with my users. Would like to get it working again after upgrading to 2.1.1 - Thanks in anticipation!

rapalero


pikeman

@rapalero Which one do you mean, imgbb or postimage?

rapalero


Marina3


jsx

This mod works properly on SMF 2.1.3

You can download this mod on this page:

https://imgbb.com/mod

But unfortunately, the download on this page has not been working for several days. I reported this issue to imgbb and got no response. There is no support for imgbb users. It's really nasty.

Kindred

the mod might not support php 8.1, which I believe is your version...

However. Marina3 ---    your "reports" are, for the most part, useless.   Saying "Not work on smf 2.1.3." doesn;t give ANY context.

For *EACH* report of a failure, you need to specify your SMF version, PHP version, mod version and WHAT the actual failure is.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

jsx

The download is already working on the imgbb website.

jsx

Quote from: jsx on May 15, 2021, 04:08:30 AMDoes anyone know how to replace the dot before "Add image to post" in the code with an icon for this service?





imgbb.js:

if(imgbb_lang=="en"){imgbb_lang="";}else if(imgbb_lang.indexOf(".")===-1){imgbb_lang+=".";}if(window.location.hash){var imgbb_text;var imgbb_hash;if(window.name.indexOf("imgbb_")===-1){imgbb_text=window.name;imgbb_hash=window.location.hash.substring(1).split("_");}else{imgbb_text=window.location.hash.substring(1);imgbb_hash=window.name.split("_");}if(imgbb_text!="" && imgbb_hash.length>1){if(imgbb_hash[0]=="imgbb"){var imgbb_id=imgbb_hash[1];imgbb_text=decodeURIComponent(imgbb_text);if(imgbb_text.length>20){if(opener!=null && !opener.closed){var imgbb_area=opener.document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i++){if(i==imgbb_id){var editor=false;if(typeof opener.smf_editorArray==='object'){for(var A in opener.smf_editorArray){if(opener.smf_editorArray[A].opt.sUniqueId==imgbb_area[i].id){opener.smf_editorArray[A].insertText(opener.smf_editorArray[A].getText()+imgbb_text,true);editor=true;}}}if(editor==false){imgbb_area[i].value=imgbb_area[i].value+imgbb_text;}opener.focus();window.close();}}}}window.location.replace("//" + imgbb_lang + "imgbb.com/upload?mode=code&url=" + encodeURIComponent(document.location.href));}}}function imgbb_insert(){var imgbb_area=document.getElementsByTagName('textarea');for(var i=0;i<imgbb_area.length;i++){if(imgbb_area[i].name && !imgbb_skip_textarea.test(imgbb_area[i].name)){var attr=imgbb_area[i].getAttribute('data-imgbb');if(attr!="true"){var imgbb_div=document.createElement('div');imgbb_div.setAttribute('class',"imgbb");var imgbb_a=document.createElement('a');imgbb_a.innerHTML=imgbb_add_text;imgbb_a.href="javascript:imgbb_upload("+i+");";var imgbb_bullet=document.createElement('span');imgbb_bullet.setAttribute('class',"imgbb_bullet");imgbb_bullet.innerHTML="&#160;&#8226;&#160;";imgbb_div.appendChild(imgbb_bullet);imgbb_div.appendChild(imgbb_a);imgbb_area[i].setAttribute('data-imgbb',"true");if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].parentNode.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].parentNode.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.parentNode.appendChild(imgbb_div);}else if(new RegExp("quick","i").test(imgbb_area[i].name)==false && imgbb_area[i].nextElementSibling && imgbb_area[i].nextElementSibling.nextElementSibling && new RegExp("resize","i").test(imgbb_area[i].nextElementSibling.nextElementSibling.id)){imgbb_div.setAttribute('style',imgbb_style);imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else{if(imgbb_area[i].nextSibling.nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling.nextSibling);}else if(imgbb_area[i].nextSibling){imgbb_area[i].parentNode.insertBefore(imgbb_div,imgbb_area[i].nextSibling);}else{imgbb_area[i].parentNode.appendChild(imgbb_div);}}}}}}function imgbb_upload(areaid){window.open("//" + imgbb_lang + "imgbb.com/upload?mode=smf&url=" + encodeURIComponent(document.location.href),"imgbb_" + areaid,"resizable=yes,width=720,height=550");return void(0);}if(typeof(window.addEventListener)=='function'){window.addEventListener('DOMContentLoaded',imgbb_insert,false);window.addEventListener('load',imgbb_insert,false);}else if(typeof(window.attachEvent)=='function'){window.attachEvent('onload',imgbb_insert);}else{if(window.onload!=null){var old_onload=window.onload;window.onload=function(e){old_onload(e);imgbb_insert();};}else{window.onload=imgbb_insert;}}for(var i=1;i<12;i+=2){setTimeout("imgbb_insert()",i*1000);}imgbb_insert();}

Solution:

Find code:

imgbb_bullet.setAttribute('class',"imgbb_bullet");imgbb_bullet.innerHTML="&#160;&#8226;&#160;"
Replace with this code:

imgbb_bullet.setAttribute('class',"imgbb_bullet");imgbb_bullet.innerHTML="<img src='https://simgbb.com/images/favicon.png'width='16'height='16'>&nbsp;"

Arskrigitsioniets

SMF 2.1.4., it uploads only thumbnails 180x180, I don't see a possibility to change this behavior.

Advertisement: