• Resolved Lysefjordcam

    (@kmhaugen)


    Hi,

    Some fyi to start with so you might better understand my request ??
    I’m running a volenteer non-profit site to promote my beautiful home area.
    I’ve set up a very nice Axis Q6045-E MK-II PTZ HD network camera to take pictures around the fjord area I live.

    For me it was love-at-first-sight with your Tracks theme. I just love the large picture at the top on post/pages which makes a big impact on visitors – and of course the themes simplicity and responsiveness is just great! ??

    You can check out the site if you want: https://www.lysefjordcam.com

    My request is that I would love to have the different webcam pictures as a feature image on my pages. I’m currently trying a new plugin called Nelio External Featured Image, but it looks like it only support certain functions.

    This is what the plugin FAQ says:
    WordPress offers more than one function for inserting featured images. Unfortunately, only one of them has a filter we can use. If your theme is not using the (get_)the_post_thumbnail, then our plugin will not be able to insert external featured images.

    What do I need to do to get external feature image support on your Tracks theme?

    All the best
    Morten Haugen

Viewing 8 replies - 1 through 8 (of 8 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Hi Morten,

    Thanks for using Tracks! That’s a really cool idea.

    Tracks uses a different function (wp_get_attachment_image_src) for a little more control over the featured image display. Luckily, the function for outputting the featured image can be easily overridden with a child theme. You can click here to download an empty Tracks child theme.

    You’ll want to copy the “ct_tracks_featured_image” function from Tracks’ functions.php file into the Tracks Child Theme’s functions.php file. Then, you can switch out the function used for getting/outputting the featured image.

    Thread Starter Lysefjordcam

    (@kmhaugen)

    Hi Ben,

    Thank you for getting back to me so quickly ??

    With great confidence I followed your instructions only to get to a point I just had to admit I’m not a programmer – this was a to-big-task for me as a “one man crew” :/

    So my question is; how do I re-build the “wp_get_attachment_image_src” that I now have in the Track_Child functions.php to become a “get_the_post_thumbnail” type of function?

    I tried… I really did…
    Besides that I unintentionally took down the site a few times.. oops;
    The only thing I accomplished was to remove the feature-image with a white box of nothing. ??

    Help me Ben Sibley, you’re my only hope. (Freely quoted from Star Wars)

    Morten

    Theme Author Ben Sibley

    (@bensibley)

    A valiant effort ??

    I installed the plugin and was able to get everything working nicely with the following code.

    Here is the function you need for the functions.php file:

    function ct_tracks_featured_image() {
    
    	global $post;
    
    	echo '<div class="featured-image">';
    		echo get_the_post_thumbnail();
    	echo '</div>';
    }

    And then add the following to the style.css file in the child theme:

    .featured-image {
        height: auto;
        padding-bottom: 0;
        line-height: 0;
    }
    .featured-image img {
        height: 100%;
        width: 100%;
    }

    That should do the trick!

    Thread Starter Lysefjordcam

    (@kmhaugen)

    Hi Ben,

    That was quick, thanks.

    …but I must be doing something wrong!?
    I’m using your code now and it looks almost ok. All thats missing is the picture.
    I can see in the page source that the correct ref to external image is applied, but the image box is still white. What can be wrong? Do you have time for a quick look on the page?

    https://www.lysefjordcam.com

    All the best
    Morten

    Thread Starter Lysefjordcam

    (@kmhaugen)

    Ben,

    I’ve disabled the child tweaked function for now. It seems i can’t get it to work atm.
    – and its getting late here in Norway. Thanks a lot for your great support so far!

    One final thought
    I was thinking about another approach that might work to get external web cam images.
    Is it possible to use custom CSS instead of the plugin; to override background-image for a given feature image on a given page based on page ID?

    Morten

    Thread Starter Lysefjordcam

    (@kmhaugen)

    Ben,
    I got it to work (YEAH!) with som code i found on the plugin support pages.

    The details are as follows:

    Go to functions.php lines 278-313, function ct_tracks_featured_image. You'll see there are two if blocks, the former checks if ( has_post_thumbnail( $post->ID ) ), the second if ( $has_image == true ). Between these two if blocks, add the following code:
    
    if ( function_exists( 'uses_nelioefi' ) && uses_nelioefi( $post->ID ) ) {
      $has_image = true;
      $image = nelioefi_get_thumbnail_src( $post->ID );
    }
    This new block basically checks if the current post ($post->ID) has an external featured image and, if it does, it gets the URL of that image.

    I did copy only the function from the main theme over to the child theme and did the “patch” on that. And its working super smooth !! ??

    Thanks again for your support and you have a good one!

    All the best
    Morten

    Theme Author Ben Sibley

    (@bensibley)

    No problem, glad you got it working ??

    Thread Starter Lysefjordcam

    (@kmhaugen)

    Resolved…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘External featured image for latest webcam image’ is closed to new replies.