搜索本站精品资源

本站所有资源均为高质量资源,各种姿势下载。

钻石
hello图床URL网址上传图片和本地图片上传对接API方式 暂无演示

独家
hello图床URL网址上传图片和本地图片上传对接API方式

售价:
¥10 积分
  • 普通用户购买价格 : 10积分
  • 钻石会员购买价格 :0积分
  • 终身钻石购买价格 : 免费
QQ咨询

    Warning: Invalid argument supplied for foreach() in /www/wwwroot/www.ricaiji.com/wp-content/themes/ripro-chlid/single.php on line 294

升级尊贵会员
享受全站VIP待遇

27+
会员已经加入
  • 文章介绍
  • hello图床URL网址上传图片和本地图片上传对接API方式-日采集
    hello图床URL网址上传图片和本地图片上传对接API方式-日采集

    /ripro/inc/codestar-framework/options/options.theme.php在最下面添加如下代码

    CSF::createSection($prefix, array(
    ‘title’ => ‘图床设置‘,
    ‘icon’ => ‘fa fa-circle’,
    ‘fields’ => array(

    array(
    ‘id’ => ‘is_hellotc’,
    ‘type’ => ‘switcher’,
    ‘title’ => ‘hello图床‘,
    ‘label’ => ‘申请地址:https://www.helloimg.com/’,
    ‘default’ => false,
    ),
    array(
    ‘id’ => ‘hellotc’,
    ‘type’ => ‘fieldset’,
    ‘title’ => ‘配置详情’,
    ‘fields’ => array(
    array(
    ‘id’ => ‘hellotc_url’,
    ‘type’ => ‘text’,
    ‘title’ => ‘API地址’,
    ‘default’ => ‘https://www.helloimg.com/newapi/2/upload/?format=json’,
    ‘desc’ => ‘API地址获取QQ群536666681’,
    ),
    array(
    ‘id’ => ‘hellotc_user’,
    ‘type’ => ‘text’,
    ‘title’ => ‘帐号’,
    ‘default’ => ”,
    ),
    array(
    ‘id’ => ‘hellotc_pass’,
    ‘type’ => ‘text’,
    ‘title’ => ‘密码’,
    ‘default’ => ”,
    ‘attributes’ => array(
    ‘type’ => ‘password’,
    ‘autocomplete’ => ‘off’,
    ),
    ),

    ),
    ‘dependency’ => array(‘is_hellotc’, ‘==’, ‘true’),
    ),

    ),

    ));

     

    修改主题的functions.php

    require_once get_template_directory() . ‘/inc/tuchuang/tc.php’;

    然后上传附件解压到inc文件里即可 也就是文件夹tuchuang放在ripor/inc路径里

     

    如果自己懂代码直接附上tc.php代码ripor/inc/tuchuang/tc.php

    <?php
    if(_cao(“is_hellotc”)){
    add_action(‘media_buttons’, ‘add_my_media_button’);

    }

    function add_my_media_button() {
    $currentUser = wp_get_current_user();
    if(!empty($currentUser->roles) && in_array(‘administrator’, $currentUser->roles)){

    $tcConfig = _cao(‘hellotc’);
    $DOMAIN=$tcConfig[‘hellotc_url’];
    //用户邮箱
    $user_mail=$tcConfig[‘hellotc_user’];
    //用户密码
    $user_pawd=$tcConfig[‘hellotc_pass’];
    }
    else
    return 0;
    echo ‘
    <a onclick=”javascript:urltp();” id=”urltp” class=”button button-primary”><i class=”fa fa-picture-o” aria-hidden=”true”></i>Hello图床网址上传图片</a>
    <input id=”up_to_chevereto” type=”file” accept=”image/*” multiple=”multiple”/>
    <label for=”up_to_chevereto” id=”up_img_label”><i class=”fa fa-picture-o” aria-hidden=”true”></i>Hello图床本地上传图片</label>

    ‘;
    ?>
    <style type=”text/css”>
    #up_to_chevereto {
    display: none;
    }
    #up_img_label {
    color: #fff;
    background-color: #16a085;
    border-radius: 5px;
    display: inline-block;
    padding: 5.2px;
    }
    </style>
    <script src=”https://libs.baidu.com/jquery/2.0.0/jquery.min.js”></script>
    <script type=”text/javascript”>

    $(‘#up_to_chevereto’).change(function() {
    window.wpActiveEditor = null;
    for (var i = 0; i < this.files.length; i++) {
    var f=this.files[i];
    var user_email = ‘<?=$user_mail ?>’;
    var user_password = ‘<?=$user_pawd ?>’;
    var formData=new FormData();
    formData.append(‘login-subject’,user_email)
    formData.append(‘password’,user_password)
    formData.append(‘source’,f);
    $.ajax({
    async:true,
    crossDomain:true,
    url:'<?=$DOMAIN;?>’,
    type : ‘POST’,
    processData : false,
    contentType : false,
    data:formData,
    beforeSend: function (xhr) {
    $(‘#up_img_label’).html(‘<i class=”fa fa-spinner rotating” aria-hidden=”true”></i> 本地图片上传中…’);
    },
    success:function(res){
    wp.media.editor.insert(‘<a href=’+res.image.url+’><img src=’+res.image.url+’ alt=’+res.image.title+’></img></a>’);
    $(“#up_img_label”).html(‘<i class=”fa fa-check” aria-hidden=”true”></i>本地图片上传成功,继续上传’);
    },
    error: function (){
    $(“#up_img_label”).html(‘<i class=”fa fa-times” aria-hidden=”true”></i> 本地图片上传失败,重新上传’);
    }
    });
    }
    });

    function urltp() {

    window.wpActiveEditor = null;
    str =prompt(“这里输入图片网址”);
    if(str.length>5){
    var f=str;
    var user_email = ‘<?= $user_mail ?>’;
    var user_password = ‘<?=$user_pawd ?>’;
    var formData=new FormData();
    formData.append(‘login-subject’,user_email)
    formData.append(‘password’,user_password)
    formData.append(‘source’,f);
    $.ajax({
    async:true,
    crossDomain:true,
    url:'<?=$DOMAIN;?>’,
    type : ‘POST’,
    processData : false,
    contentType : false,
    data:formData,
    beforeSend: function (xhr) {
    $(‘#urltp’).html(‘url图片上传中…..’);
    },
    success:function(res){
    wp.media.editor.insert(‘<a href=’+res.image.url+’><img src=’+res.image.url+’ alt=’+res.image.title+’></img></a>’);
    $(“#urltp”).html(‘url图片上传成功,继续上传’);
    },
    error: function (){
    $(“#urltp”).html(‘url图片上传失败,重新上传’);
    }
    });
    }
    };
    </script>

    <?php

    }

    hello图床URL网址上传图片和本地图片上传对接方式