filter_the_content() public static method

Identify images in post content, and if images are local (uploaded to the current site), pass through Photon.
public static filter_the_content ( string $content ) : string
$content string
return string
Beispiel #1
0
 public function gallery_shortcode($val, $atts)
 {
     if (!empty($val)) {
         // something else is overriding post_gallery, like a custom VIP shortcode
         return $val;
     }
     global $post;
     $this->set_atts($atts);
     $attachments = $this->get_attachments();
     if (empty($attachments)) {
         return '';
     }
     if (is_feed() || defined('IS_HTML_EMAIL')) {
         return '';
     }
     if (method_exists($this, $this->atts['type'] . '_talavera')) {
         // Enqueue styles and scripts
         $this->default_scripts_and_styles();
         $gallery_html = call_user_func_array(array($this, $this->atts['type'] . '_talavera'), array($attachments));
         if ($gallery_html && class_exists('Jetpack') && class_exists('Jetpack_Photon')) {
             // Tiled Galleries in Jetpack require that Photon be active.
             // If it's not active, run it just on the gallery output.
             if (!in_array('photon', Jetpack::get_active_modules())) {
                 $gallery_html = Jetpack_Photon::filter_the_content($gallery_html);
             }
         }
         return $gallery_html;
     }
     return '';
 }
Beispiel #2
0
 public function gallery_shortcode($val, $atts)
 {
     if (!empty($val)) {
         // something else is overriding post_gallery, like a custom VIP shortcode
         return $val;
     }
     global $post;
     $this->set_atts($atts);
     $attachments = $this->get_attachments();
     if (empty($attachments)) {
         return '';
     }
     if (is_feed() || defined('IS_HTML_EMAIL')) {
         return '';
     }
     if (in_array($this->atts['type'], self::$talaveras)) {
         // Enqueue styles and scripts
         self::default_scripts_and_styles();
         // Generate gallery HTML
         $gallery_class = 'Jetpack_Tiled_Gallery_Layout_' . ucfirst($this->atts['type']);
         $gallery = new $gallery_class($attachments, $this->atts['link'], $this->atts['grayscale'], (int) $this->atts['columns']);
         $gallery_html = $gallery->HTML();
         if ($gallery_html && class_exists('Jetpack') && class_exists('Jetpack_Photon')) {
             // Tiled Galleries in Jetpack require that Photon be active.
             // If it's not active, run it just on the gallery output.
             if (!in_array('photon', Jetpack::get_active_modules()) && !Jetpack::is_development_mode()) {
                 $gallery_html = Jetpack_Photon::filter_the_content($gallery_html);
             }
         }
         return trim(preg_replace('/\\s+/', ' ', $gallery_html));
         // remove any new lines from the output so that the reader parses it better
     }
     return '';
 }