Tìm thấy 2 mục

[Code] Thay Úp ảnh mặc định thành úp ảnh Imgur

Code này là đơn giản nhất trong các code úp ảnh mà diễn đàn đã share . Chỉ cần chọn thẳng ảnh trong máy để up , khi úp xong sẽ tự động hiện link ảnh thẳng vào bài viết . Nhược điểm là phải úp từng lượt và không úp được bằng url .

Topics tagged under imgur on Diễn Đàn Hỗ Trợ FM  S2c32w0

Topics tagged under imgur on Diễn Đàn Hỗ Trợ FM  CHvQzMV

BƯỚC 1: TẠO JS THAY THẾ


Vào modules >> HTML & JAVASCRIPT >> Javascript codes management
Tạo js này và click vào In all the page

Code:

;window['FormData'] && $(function(){$(function(){
  
      var imgur_client_id = 'Thay ID ở Đây'; // you will get it via http://api.imgur.com/oauth2/addclient
  
      var current = 0, uploaded, xhrs, file_selector, button = $('.sceditor-button-servimg').off().click(function(){
        if(current) return finish();
        if(!file_selector) file_selector = $('<input type="file" multiple/ accept="image/*">').css({position:'absolute', top:-100}).appendTo('body').change(function (e) {
          var files = e.target.files, fd, len;
          uploaded = [], xhrs = [];
          for (var i = 0, len = files.length; i < len; i += 1) {
            if (files[i].type.indexOf('image/') && files[i].type !== 'application/pdf') continue;
            current++;
            fd = new FormData();
            fd.append('image', files[i]);
            (function(xhr){
              var num = i, xhr = jQuery.ajaxSettings.xhr();
              xhrs.push(xhr);
              xhr.open('POST', 'https://api.imgur.com/3/image');
              xhr.setRequestHeader('Authorization', 'Client-ID '+imgur_client_id);
              xhr.onreadystatechange = function () {
                if (xhr.readyState !== 4) return;
                current--;
                if (xhr.status === 200) {
                  var res = JSON.parse(xhr.responseText);
                  uploaded[num] = res.data.link;
                }
                if(!current) finish();
              };
              xhr.send(fd);
            })();
          }
          if(current) button.css({background:'url(http://i.imgur.com/EMsOJtZ.gif) no-repeat'});
        });
        file_selector.click();
        return false;
      }).children();
      var finish = function(){
        for(var i=0; i < xhrs.length; i++) {
            if(xhrs[i].readyState == 4) continue;
            xhrs[i].onreadystatechange = function(){};
            xhrs[i].abort();
        }
        for(var i=0; i < uploaded.length; i++) {
          if(uploaded[i] === undefined) continue;
          $('body').find('.sceditor-button-image').click().end().find('.sceditor-insertimage').find('#image').val(uploaded[i]).end().find('input.button').click();
          $('#text_editor_textarea').sceditor('instance').insertText('\n');
        }
        button.removeAttr('style');
        current = 0;
        file_selector.wrap('<form>').closest('form').get(0).reset();
        file_selector.unwrap();
        return false;
      };
    })});


BƯỚC 2: THAY CLIENT ID VÀO JS


Thay client ID đã tạo ở trang Imgur vào chữ 'Thay ID ở đây' dòng 3 của Js
Nếu chưa biết tạo Client ID thì vào đọc hướng dẫn ở topic này :
http://www.hotrofm.net/t304-code-up-anh-len-imgur-mien-phi


Nguồn : fmdesign

Tags: #code #imgur #bbcode

[Code] bbcode up ảnh imgur thay thế code tinypic forumotion

bbcode up ảnh imgur thay thế code tinypic


Việc sử dụng up ảnh trên tinypic mình thấy load chậm chậm sao ấy, hơn thế nữa cũng ko quản lý dc ảnh, vì vậy mình tích hợp code up ảnh của baivong từ devs vào nút bbcode cho các bạn sử dụng sceditor mặc định của forumotion

Mặc định:
Topics tagged under imgur on Diễn Đàn Hỗ Trợ FM  Qk3U4y8

Imgur:
Topics tagged under imgur on Diễn Đàn Hỗ Trợ FM  GKYVudi

Bước 1: tạo trang html up ảnh imgur


Đầu tiên các bạn làm theo hướng dẫn ở topic này

http://www.hotrofm.net/t304-code-up-anh-len-imgur-mien-phi

Lưu lại html và Nhớ lại link html đó ví dụ như hotrofm này là http://www.hotrofm.net/h11-page 

Bước 2: Tạo js thay thế up ảnh cũ tinypic forumotion cũ


sau đó vào modules > HTML & JAVASCRIPT >> Javascript codes management

tạo js này không click vào đâu cả

Code:

$(window).load(function() {
    $('.sceditor-group:nth-child(4)').prepend('<a class="sceditor-button sceditor-button-upanh-hotrofm" title="Úp ảnh"><div></div></a>');
    $('.sceditor-button-upanh-hotrofm').click(function() {
        if ($('#upanhhotrofmPop').css('display') == 'none') {
            var y = $('.sceditor-button-upanh-hotrofm').offset().top +25;
            var x = $('.sceditor-button-upanh-hotrofm').offset().left;
            $('#upanhhotrofmPop').show().css('top',y + 'px').css('left',x + 'px');
        }
        else $('#upanhhotrofmPop').hide();
    });
$( ".sceditor-button-servimg" ).remove();
$('body').append('<div id="upanhhotrofmPop" style="display:none;position:absolute;z-index:50000;"><iframe src="http://www.domain.com/h1-page" scrolling="auto" allowtransparency="true" frameborder="0" width="300" height="400">Update your browser for tinypic.com</iframe></div><style>.sceditor-button-upanh-hotrofm div {background-position: 0 -644px;}</style>');
});


sau đó link http://www.domain.com/h1-page thành link html của bạn

Bước 3. Cho code bbocde up ảnh vào chỗ cần hiện


Code:

<script src="link.js" type="text/javascript">


Thường thì để ở viewtopicbody. postingbody


Tags: #code #forumotion #bbcode #imgur