WordPress.org

Forums

[resolved] Specify image size with $image['url'] (SMOF and ACF) (3 posts)

  1. mak1wp
    Member
    Posted 2 years ago #

    Hello,

    I'm using SMOF (slightly modified options framework) to display a (flexslider) slider, but haven't a clue how to specify a cropped image size. ie. thumbnail.

    Huge thanks in advance if anybody can help me with this.

    The PHP used to display the slider is:

    <?php
         $slides = $data['pingu_slider']; //get the slides array
    		foreach ($slides as $slide) {
    		echo
    	'<li>
    	<a href="'. $slide['link']. ' ">
    	<img src="' . $slide['url' ] . '" />
    	</a>
    
    		<div class="flex-title">'.  $slide['title']. ' </div>
    		<div class="flex-caption">'. $slide['description']. ' </div> 
    
    		</li>';
    }
    ?>

    I'm looking to somehow specify a custom crop size with the $slide['url' ]

    I'm also using ACF (advanced custom fields) - again with flexslider - to display gallery post type slides. I have exactly the same issue here, where the URL is being pulled in, with no clue how to specify the 'thumnail' URL for example.

    The code used for the ACF gallery is:

    <?php
    	$images = get_field('post_gallery');
    	if( $images ): ?>
    
        <div id="slider" class="gallery-slider">
        	<ul class="slides">
                <?php foreach( $images as $image ): ?>
                    <li>
                        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                        <div class="slide-caption"><?php echo $image['caption']; ?></div>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    <?php endif; 
    
    ?>

    A massive thanks to anyone who can shine some light on this for me.

    Thanks

  2. mak1wp
    Member
    Posted 2 years ago #

    I'm a numpty. Looks like this isn't a possibility.

    Solution:

    ACF - instead of using:
    $image['url']

    I've used
    $image['sizes']['thumbnail']

    SMOF - I'm not too sure how to create arrays and such. So instead of using the options framework to add a slide, I've done it via a custom post type - with help from this link http://wp.tutsplus.com/tutorials/create-a-responsive-slider-plugin-with-flexslider/

  3. diego.webdg
    Member
    Posted 1 year ago #

    THANK YOU so much!!!

Topic Closed

This topic has been closed to new replies.

About this Topic