Drupal 8批次上載圖像

Submitted by saladlam on

用Drupal的CKEditor自帶的Image upload功能,插入一大堆圖像,實在是太勞累。為了方便一次過上載一大堆圖像,寫了一個模組做以下工作。

  1. 把圖像檔案放在"public://"內的某個目錄
  2. 寫一個Controller,做
    1. 讀取目錄內的圖像檔案
    2. 用file_save_data()註冊檔案,會得到一個File content entity object
    3. 砌用來貼在文章內的html程式碼
    4. 刪除目錄內的檔案
    5. 顯示html程式碼

很簡單的程式,一兩小時內就可以完成。以前用數十分鐘都做不完的步驟,而家十分鐘內就可以完成。

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
Enter the characters shown in the image.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.