一直以來都把網誌的圖片放在Dropbox,但最近收到Dropbox通知,3/15準備把Public的公開資料夾功能拿掉,雖然還是可以用”Sharing links”as a method,allows images to be externally linked,but this conversion task is too massive,and it's hard to ensure it won't need to be adjusted again in the future,so it's better to just consider moving the images to a more stable location。
一開始有考慮Flickr,但雅虎對於免費服務的做法實在讓我有些擔心,加上後來看到有人說,Flickr拿來作圖床的速度有點偏慢,因此就放棄。
後來看了一下主機商ACSite給的空間與頻寬不算少,乾脆就移回自己的空間,雖然圖片檔案不少,所幸以往都有做過處理在上傳,因此整體的體積比我預期小上許多。
本想愚公移山的一篇一篇做修改,後來想到應可從後端資料庫直接批次修改,跟同事請教了SQL語法後,確認可用Replace語法達成。
試了好一陣子,總算把語法修對,以下為紀錄:
==
- 先以SELECT確認條件下對。(下面如果沒加入’ID’欄位,新版phpMyAdmin會出現要求unique欄位的錯誤)
SELECT ID, REPLACE (`post_content`, ‘https://dl.dropboxusercontent.com/u/906344/image',
‘https://it-help.tips/img') FROM `lee_wp_posts` WHERE `post_title` LIKE '%Running Foxy on Ubuntu%';
- After confirming there are no errors,Execute with the following syntax
UPDATE `lee_wp_posts` SET `post_content` = REPLACE(`post_content`,
‘https://dl.dropboxusercontent.com/u/906344/image/', ‘https://it-help.tips/img/')
[Related Links]
- MySQL's REPLACE function – Linux Technical Notes








Leave a Reply