Support

Account

Forum Replies Created

  • Hi again, I’m just coming back to this once more!

    I realised I’m not 100% which field I should be updating.

    I have a Radio Button (size) that is an option on image attachments.
    I also have a Gallery field that holds those images.

    I’d like the images to take the default value (med) when they are uploaded or a page with a gallery is published (as the gallery might contain images that don’t have a value set by the user yet)

    Do I use the update_field() function on the gallery field or the radio button?

    I hope that makes sense…

  • I just replied but it seems to have vanished.

    Thanks for your reply, however after a few attempts I’m stuck and not sure where to place the foreach loop you mention.

    I have a galley (I’ve stripped back the code here)

    <?php //Gallery images
    
    $images = get_field('image_gallery');
    $size = 'full';
    
    if( $images ): ?>
    	<?php foreach( $images as $image ): ?>
    		<img class="grid-entry" src="<?php echo $image['url'];?>" alt="<?php echo $image['alt']; ?>" />
    	<?php endforeach; ?>
    <?php endif; ?>

    Could I weave the the update_field into that foreach loop?
    Or does it need to be somewhere else?

    e.g.

    <?php //Gallery images
    
    $images = get_field('image_gallery');
    $size = 'full'; //
    
    $count = (int) get_field('field_59b6acbe2a8d2');
    
    if( $images ): ?>
    	<?php foreach( $images as $image ): 
    		// increase
    		$count++;
    		// update
    		update_field('field_59b6acbe2a8d2', $count); ?>
    		<img class="grid-entry" src="<?php echo $image['url'];?>" alt="<?php echo $image['alt']; ?>" />
    	<?php endforeach; ?>
    <?php endif; ?>

    Once that is working, does it only take a refresh of the page for it to update the images?

    Many thanks

  • Hi James,

    Thanks or your reply. However having had a few attempts I’m ot sure I fully understand what I need to do.

    I have a gallery on some certain page tmeplates and in a custom post type.

    <?php //Gallery images
    
    			$images = get_field('image_gallery');
    			$size = 'full';
    
    			if( $images ): ?>
    			      <div id="masonry-loop">
    			      	<div class="grid-sizer"></div>
        					<div class="gutter-sizer"></div>
    					<?php foreach( $images as $image ): ?>
    						<img class="grid-entry" src="<?php echo $image['url'];?>" alt="<?php echo $image['alt']; ?>" />
    					<?php endforeach; ?>
    			      </div>
    			<?php endif; ?>

    Do I work the update_field into the gallery loop?
    For example:

    <?php //Gallery images
    
    			$images = get_field('image_gallery');
    			$size = 'full';
    			$count = (int) get_field('field_59b6acbe2a8g6');
    
    			if( $images ): ?>
    			      <div id="masonry-loop">
    			      	<div class="grid-sizer"></div>
        					<div class="gutter-sizer"></div>
    					<?php foreach( $images as $image ): ?>
    			// increase
    			$count++;
    			// update
    			update_field('field_59b6acbe2a8g6', $count);						
    			<img class="grid-entry" src="<?php echo $image['url'];?>" alt="<?php echo $image['alt']; ?>" />
    					<?php endforeach; ?>
    			      </div>
    			<?php endif; ?>

    If so I can’t seem to get it to work.
    Any pointers would be greatly appreciated.

    Many thanks,

  • I guess what I’m asking is where in your plugin is the HTML I can see when looking at my post page with my text field on created.

    I’d like to add:
    onblur="myFunction()"

    to this HTML created by ACF
    <input type="text" id="acf-field-miles" class="text" name="fields[field_52f526e67d916]" value="8000" placeholder="e.g 10,000" testing="">

    Is it line 79 in text.php?

    I can’t seem to work out where exactly that is created. Sorry 🙁

  • Ok thanks.

    I just meant an onblur event , opposite of onfocus. So when the user tabs out of a field. Not an actual blur effect.

    The conversion and coding are quite straight forward, I’m just no clear where I’d put the code as it’s being created by ACF.

    Here’s a version of what I mean. Fill in the miles tab to the Kilometres and it auto fills.

    Would you be able to suggest where or what I might target using the ACF plugin?

    Thanks again.

  • Turns out it was the latest version of Flexslider (v2.2.2).

    Version 2.2.1 works fine!

    I hate stuff like that, had me going round in circles for ages…

    Cheers,

    S

  • ok, so it looks as if everything is fine apart from the fact that in my 4 image gallery, the Flexslider is highlighting thumbnail 1 and displaying image 4, then highlighting thumbnail 2 and displaying image 1 etc.

    thumbnail 1 displays image 4
    thumbnail 2 displays image 1
    thumbnail 3 displays image 2
    thumbnail 4 displays image 3
    then it loops around.

    The html that is printed by the php is fine. The images match the thumbnails. When I reorder via the gallery field, the order is correct.

    So it appears to be something to do with the flexslider I guess.
    I’ll struggle on. Thanks for your time and suggestions as to what to check.

  • Just checked the thumbnail and image, even though the file names match up, the images are actually diffirent.

    I just tried a new post with new media(images). I create new post, click the gallery field, upload 4 images, rearrange them in the gallery field and publish.

    Results in a post with the thumbnails in the order I’ve created and the main images in the order they were uploaded.

    Strange.

    If I take out the JS I end up with a list of 4 original images and no thumbs.

    Personally, I’m stumped (which isn’t saying much!)

  • Hello,

    The generated html is as follows:

    <!-- Start Flexslider -->
    <div class="flexslider">
        <ul class="slides">
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy.jpg" alt="" />
                </li>
         </ul>
    </div>
    <!-- End Flexslider -->

    Which is odd because it looks as if the images and thumbs should match up.

    I was using a Flexslider example and creating the thumbs in this line (from previous posted code)

    <li data-thumb="<?php echo $image['sizes']['thumbnail']; ?>">

    The Flexslider suggested code is as follows:
    JS

    // Can also be used with $(document).ready()
    $(window).load(function() {
      $('.flexslider').flexslider({
        animation: "slide",
        controlNav: "thumbnails"
      });
    });

    HTML

    <!-- Place somewhere in the <body> of your page -->
    <div class="flexslider">
      <ul class="slides">
        <li data-thumb="slide1-thumb.jpg">
          <img src="slide1.jpg" />
        </li>
        <li data-thumb="slide2-thumb.jpg">
          <img src="slide2.jpg" />
        </li>
        <li data-thumb="slide3-thumb.jpg">
          <img src="slide3.jpg" />
        </li>
        <li data-thumb="slide4-thumb.jpg">
          <img src="slide4.jpg" />
        </li>
      </ul>
    </div>

    I’ve kinda mashed these together after watching your vimeo video example.

    When I change the order of the thumbnails via the Gallery Field in the WP Post screen, should it (in theory) update the order of the thumbnails and full size images? (I understand it’s mostly likely me, so when I say ‘in theory’ I mean no offence!)

  • Thanks for the reply. I get what you’re saying. Unfortunately the custom fields in the theme are split over 2 files and I don’t have enough knowledge to know exactly what to edit.

    So I decided to start fresh and build my own… I’ve already learnt a lot.

    Again, thanks for your time.

  • Hello,

    Yeah, I figured that, but there isn’t really a way to ‘import’ so-to-speak back into an install of ACF?

    I’m just struggling to work it out in the code. Ah well.

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