php – 在屬性 src 使用 data url 的寫法

php 使用data url 的function :

function data_url($file, $mime)
{
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64);
}

使用Codeigniter,在Controller 裡面的function 可以這樣寫:
public function dataurl()
{
$this->load->helper('file');
$base64 = base64_encode(read_file(你的圖片實際位置));
return $url = 'data:jpg;base64,' . $base64; //我這邊圖片類型直接寫jpg,就不寫判斷了
}

可參考:
http://www.player.idv.tw/prog/index.php/Data_URI_scheme#PHP
http://blog.darkthread.net/post-2010-11-05-data-uri.aspx

 

jQuery – TinyMCE 網址轉換設定

TinyMCE 對於同 domain 以 http 開頭的絕對網址,預設會雞婆地作 url 相對路徑的轉換
TinyMCE 提供 3 + 1 組選項設定,可供自由運用組合。

當 convert_urls 為 true 時 (預設值),底下 3 組可交互使用
relative_urls 布林值,預設為 true
remove_script_host 布林值,預設為 true
document_base_url 字串值,預設為當前程式的路徑
或單獨將 convert_urls 設定為 false 關閉網址轉換

參考:Paths/URLs are incorrect, I want absolute/relative URLs?
http://tinymce.moxiecode.com/wiki.php/TinyMCE_FAQ#Paths.2FURLs_are_incorrect.2C_I_want_absolute.2Frelative_URLs.3F

參考:URL conversion
http://tinymce.moxiecode.com/tryit/url_conversion.php

<script type="text/javascript">
// 對於同 domain 的網址或圖片連結,會以根目錄 / 作為開頭
// TinyMCE with absolute URLs on links and images
tinyMCE.init({
	relative_urls: false
});

// 對於同 domain 的網址或圖片連結,以完整 http 絕對網址開頭
// TinyMCE with absolute URLs and including domain on links and images
tinyMCE.init({
	relative_urls: false,
	remove_script_host: false
});

// 此為預設值:自動轉換同 domain 的網址或圖片連結,為相對於當前程式的路徑
// TinyMCE with relative URLs on links and images
tinyMCE.init({
	relative_urls: true // Default value
});

// 以指定好的 base url 為基礎相對位置,自動轉換同 domain 的網址或圖片連結
// TinyMCE with relative URLs on links and images to a specific page
tinyMCE.init({
	relative_urls: true, // Default value
	document_base_url: 'http://tinymce.moxiecode.com/'
});

// 不作任何 url 轉換
// TinyMCE with no url convertion
tinyMCE.init({
	convert_urls: false
});
</script>

 

 

 

轉自:http://www.doubleservice.com/2011/02/tinymce-convert-urls/