Support » Plugin: jQuery Image Lazy Load WP » the_content does not include images, preventing preg_replace

  • I am using the jQuery Image Lazy Loading Plugin on my WP 3.3.1 blog, however I have found that the_content does not include the image URLs, so the preg_replace that this function does cannot find any image URLs to replace.

    function filter_the_content($content) {
        if (is_feed()) {
            return $content;
        }
        return preg_replace_callback('/(<\s*img[^>]+)(src\s*=\s*"[^"]+")([^>]+>)/i', array($this, 'preg_replace_callback'), $content);
    }

    What I am trying to establish is where does $content get passed in by (and why does it not contain the image URLs).

    add_filter('the_content', array($this, 'filter_the_content'));

    I have found this problem with other WP image lazy loading plugins, so it’s not localised to this particular plugin.

    I am pulling my blog images from this code in single-blog.php:

    <?php
    while(the_repeater_field('blog_images')): 
    
            if(get_sub_field('blog_image_link'))
            {
                ?><a>"><img src="<?php the_sub_field('blog_image'); ?>"/></a><?php ;
            }else {
                ?><img src="<?php the_sub_field('blog_image'); ?>"/><?php ;
            }
    endwhile;
    ?>

    https://wordpress.org/plugins/jquery-image-lazy-loading/

  • The topic ‘the_content does not include images, preventing preg_replace’ is closed to new replies.