diff --git a/filter/mediaplugin/filter.php b/filter/mediaplugin/filter.php index f42f8f7b4cde..9368d102d5c9 100644 --- a/filter/mediaplugin/filter.php +++ b/filter/mediaplugin/filter.php @@ -92,6 +92,15 @@ function filter($text) { $newtext = preg_replace_callback($search, 'mediaplugin_filter_youtube_callback', $newtext); } + if ($CFG->filter_mediaplugin_enable_img) { + $search = '/]*>(.*?)<\/a>/is'; + $newtext = preg_replace_callback($search, 'mediaplugin_filter_img_callback', $newtext); + $search = '/]*>(.*?)<\/a>/is'; + $newtext = preg_replace_callback($search, 'mediaplugin_filter_img_callback', $newtext); + $search = '/]*>(.*?)<\/a>/is'; + $newtext = preg_replace_callback($search, 'mediaplugin_filter_img_callback', $newtext); + } + if (empty($newtext) or $newtext === $text) { // error or not filtered unset($newtext); @@ -230,6 +239,16 @@ class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash" ''; } +/** + * Change links to images into embedded images + */ +function mediaplugin_filter_img_callback($link, $autostart=false) { + $url = addslashes_js($link[1]); + $info = addslashes_js($link[2]); + + return ''; +} + /** * Embed video using window media player if available */ diff --git a/filter/mediaplugin/filtersettings.php b/filter/mediaplugin/filtersettings.php index bb5893d066a8..3068a79c44d1 100644 --- a/filter/mediaplugin/filtersettings.php +++ b/filter/mediaplugin/filtersettings.php @@ -22,4 +22,6 @@ $settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_youtube', get_string('mediapluginyoutube','admin'), '', 1)); +$settings->add(new admin_setting_configcheckbox('filter_mediaplugin_enable_img', get_string('mediapluginimg','admin'), '', 1)); + ?> diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 2ec37196f17c..fdb18f767322 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -560,6 +560,7 @@ $string['mediapluginrpm'] = 'Enable .rpm filter'; $string['mediapluginswf'] = 'Enable .swf filter'; $string['mediapluginyoutube'] = 'Enable YouTube links filter'; +$string['mediapluginimg'] = 'Enable auto-embedding of linked images'; $string['mediapluginswfnote'] = 'As a default security measure, normal users should not be allowed to embed swf flash files.'; $string['mediapluginwmv'] = 'Enable .wmv filter'; $string['memcachedhosts'] = 'memcached hosts';