Rewrite img src in activity entry
-
Sorry, just found that I can start threads on the forum… so I’ll just copy here what I wrote before in activity:
I have this code:
function google_image_proxy($content) {
$prefix = ’https://images2-focus-opensocial.googleusercontent.com/gadgets/proxy?url=’;
$suffix = ’&container=focus&gadget=a&no_expand=1&resize_h=0&rewriteMime=image%2F*’;
$pattern = ’/(]* ?src=)[“‘]?(https?//[^”‘ ]+)[“‘]?([^>]+>)/ism’;/* method 1, does not encode url */
//$replacement = ’${1}”’.$prefix.’${2}’.$suffix.’”${3}’;
//return preg_replace($pattern, $replacement, $content);/* method 2, preg_match then str_replace */
preg_match_all($pattern, $content, $matches);
foreach ($matches[2] as $match_url) {
//if (strpos($match_url, $prefix) !== false) { continue; }
$replacement = $prefix.urlencode($match_url).$suffix;
$content = str_replace($match_url, $replacement, $content);
}
return $content;
}add_filter(’the_content’, ’google_image_proxy’);
…that will rewrite img src in the blog’s posts and I’d like to make it rewrite the img src attribute for the images in the activity entries, too.
Can anyone do this, please?
P.S. Using the Google’s proxy might speed up loading time and also will display external images that are protected from hotlinking on the original site (source) and… I don’t know what’s a backtick.
- The topic ‘Rewrite img src in activity entry’ is closed to new replies.