Support

Account

Home Forums General Issues How to use BFI Thumb (resize) with ACF?

Solved

How to use BFI Thumb (resize) with ACF?

  • Instead of using Timthumb for image resizing I am trying something new: BFI Thumb

    It seems easy to use. Here is an example:

    $params = array( 'width' => 400 );
    echo "<img src='" . bfi_thumb( "URL-to-image.jpg", $params ) . "'/>";

    or like this:

    $params = array( 'width' => 870, 'height' => 478 );
    $image = bfi_thumb( "URL-to-image.jpg", $params );
    echo "<img src='$image'/>";

    But now I want to replace “URL-to-image.jpg” with a standard PHP ACF image snippet. For example: <? the_sub_field('start_diashow_image'); ?>

    Since I don’t really know PHP I can’t get it working …

    Has somebody an idea how to morph ACF and BFI Thumb together?

    Many thanks in advanced!

  • Okay, the solution is really easy if you know basic PHP: Here we go:

    <?php
    $params = array( 'width' => 870, 'height' => 478 );
    $image = bfi_thumb(get_sub_field('start_diashow_image'), $params);										echo "<img src='$image'/>";
    ?>

    “get_sub_field” is the key 🙂

  • This works awesome! Any idea how I might also pull the image ALT attribute along with it?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘How to use BFI Thumb (resize) with ACF?’ is closed to new replies.