iT邦幫忙

0

medium editor 如何改上傳程序?

編輯器
https://github.com/yabwe/medium-editor
上傳插件
https://github.com/orthes/medium-editor-insert-plugin

起因
https://github.com/orthes/medium-editor-insert-plugin/blob/master/dist/js/medium-editor-insert-plugin.js
我在上傳插件 medium-editor-insert-plugin.js 中找到上傳程序從1589行開始

label: '<span class="fa fa-camera"></span>',
deleteMethod: 'POST',
// deleteScript: 'delete.php',
preview: true,
// captions: true,
// captionPlaceholder: 'Type caption for image (optional)',
autoGrid: 3,
fileUploadOptions: { // See https://github.com/blueimp/jQuery-File-Upload/wiki/Options
    url: '/public/dist/editor/upload.php',
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
},
fileDeleteOptions: {},
styles: {
    wide: {
        label: '<span class="fa fa-align-justify"></span>'
        // added: function ($el) {},
        // removed: function ($el) {}
    },
    left: {
        label: '<span class="fa fa-align-left"></span>'
        // added: function ($el) {},
        // removed: function ($el) {}
    },
    right: {
        label: '<span class="fa fa-align-right"></span>'
        // added: function ($el) {},
        // removed: function ($el) {}
    },
    grid: {
        label: '<span class="fa fa-th"></span>'
        // added: function ($el) {},
        // removed: function ($el) {}
    }
},

我把上傳路徑改成他內建上傳程序 upload.php
https://github.com/orthes/medium-editor-insert-plugin/blob/master/examples/upload.php
UploadHandler.php
https://github.com/orthes/medium-editor-insert-plugin/blob/master/examples/vendors/UploadHandler.php

結果
但即便我改了路徑,就算是失敗也不會上傳 base64到編輯器中吧
但上傳圖片後又輸出 base64,不是應該報錯嗎?我還真找不到這開關在哪
難道說不是這樣改嗎?

目的
我最後目的是當按下上傳圖片後,可以將圖片傳送對後端 php 先處理過,並紀錄網址到數據庫,再吐回我處理過的網址回去 editor
這是有辦法實現的嗎?

問題1
他的 upload.php 沒有 key 的設置?就好比 html 上傳給 php 處理時,都會有 $_FILES['key'] 字段去接應,但他這裡好像沒有這個東西?

問題2
我目的是當他上傳圖片,我會將圖片丟到我服務器,並且順便給一個 url 讓他帶回去 editor,使他顯示這個網址而產生預覽圖,若網址是有效的,它就會顯示圖片對吧,我就不用透過 base64 了?因為如果一樣是 base64 回去 editor,字符數量一樣爆炸。

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答