New Landing How can we help? Cardinal First image in post not displaying in post grid

Viewing 3 posts - 16 through 18 (of 18 total)
  • Posted in: Cardinal
  • #89046
    cmwwebfx
    Member
    Post count: 30

    Here is what I have added to the genesis build I did 2 months ago

    function fallback_image() {
    global $post, $posts;
      $first_img = '';
      ob_start();
      ob_end_clean();
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches[1][0];
    
      if(empty($first_img)) {
    if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $post->post_content, $match)) {
        $first_img= 'http://i3.ytimg.com/vi/'.$match[1].'/0.jpg';
    }
      //  $first_img = "http://placehold.it/350x150";
      }
      return $first_img;
    }

    Possibly needs some checking by you first.

    #89057
    cmwwebfx
    Member
    Post count: 30

    Here is my first attempt at cleaning up, but unfortunately it doesn’t seem to work like o our genesis site.

    function custom_post_thumb_image($thumb_img_url) {
            if ($thumb_img_url == "") {
             global $post;
            ob_start();
            ob_end_clean();
            $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
            if (!empty($matches) && isset($matches[1][0])) {
            $thumb_img_url = $matches[1][0];
             }
            }
        if(empty($thumb_img_url)) {
    if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $post->post_content, $match)) {
        $thumb_img_url= 'http://i3.ytimg.com/vi/'.$match[1].'/0.jpg';
    }
      }
            return $thumb_img_url;
        }
        add_filter( 'sf_post_thumb_image_url', 'custom_post_thumb_image' );

    possibly you might see the issue in the code. Needs fresh eyes I think.

    #89082
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Let me know if you manage to sort it, else I’ll see what I can do for you 🙂

    – Ed

Viewing 3 posts - 16 through 18 (of 18 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register