[WordPress] 外掛分享: ImageBase642File

首頁外掛目錄 › ImageBase642File
10+
安裝啟用
尚無評分
1324 天前
最後更新
問題解決
WordPress 5.1+ PHP 7.1+ v1.0.1 上架:2021-06-07

內容簡介

這個外掛能夠將 base64 編碼的內嵌圖片轉換為絕對網址,並上傳至 WordPress 目錄。當文章儲存時就會進行轉換。

以下是轉換前和轉換後的範例:
轉換前:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

轉換後:
<img src="https://site.com/wp-content/uploads/2021/05/post_title_id_no.png" alt="Red dot" />

如果要在 WordPress 外使用編輯器,這款編輯器將以 base64 編碼格式嵌入圖片,這會使文章內容過長,也無法存入緩衝區,除非將 PHP 設置為非常高的記憶體使用率。

這個外掛能夠將編碼後的 base64 內嵌圖片轉換為連結,透過刪除 base64、解碼、儲存檔案,然後替換為 URL 的方式,使得文章內容變得非常簡短。此外,為了避免複製 base64 編碼到檔案時超出 PHP 記憶體限制,這個外掛會對每段 76 字元(76 byte)的 base64 編碼進行複製,保證不會因為複製圖片而過度佔用 PHP 記憶體。而且,此外掛速度比使用正則表達式還要快。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「ImageBase642File」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin converts base64 encoded inline images to an absolute URL by; uploading inline image into WordPress directory. This happens when a post is saved.
It converts this:
Red dot
To this:
Red dot
I was working on an external editor to allow users to post on WordPress, this editor embeds images in base64 encoded format. This makes post contents too long to load on-page and also cannot be stored on buffer unless PHP is set to very high memory usage.
This plugin converts the encoded base64 inline images to a link by scrapping out the base64, decode, store to file and replace with the URL. The post content becomes very short. This is over-engineered to prevent PHP memory limit when trying to copy base64 encode to file. This plugin will perform each chunk copy on 76 characters, 76 bytes. This is the base64 line limit. There will never be an out of memory when copying these images.
And, it is faster than using regex

延伸相關外掛

文章
Filter
Apply Filters
Mastodon