Support

Account

Forum Replies Created

  • Also, I forgot to mention, in the admin where you set up the image subfield, use “Image ID” for the Return Value.

  • homepage-thumb is the name I came up with, you can call it anything you like. So for instance, you could set up your functions.php file like this:

    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'my-custom-thumb-name', 97, 83, true );
    }
    
    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'my-custom-thumb-name' => __('My Custom Thumbnail'),
        ) );
    }

    my-custom-thumb-name is the name of your additional image size (you can call it whatever you want).

    I would recommend not using the term “image” for anything just to make sure it doesn’t cause any conflicts (say with WP or with another plugin.)

    Then in your template, you could use this:

    <?php
    	$attachment_id = get_sub_field('my-image-subfield-name');
    	$size = "my-custom-thumb-name";
    	$image = wp_get_attachment_image_src( $attachment_id, $size );
    ?>
    
    <td class="feature-game-img"><img src= "<?php echo $image[0]; ?>" /></td>

    my-image-subfield-name is the the name of your subfield (again, I would avoid using “image” just in case).

    Then all you need to do is echo the image there. You’ll notice the attachment_id uses get_sub_field instead of just get_field.

    Theoretically this should work, although I haven’t tested it.

    Also you might not see an image if you don’t upload new images because WP would need to create the new image size you created during the upload to the media library.

    See if that works, and if not, let me know.

  • I feel your pain, I spent all day on this, but I got it to work. I posted separately about it, maybe this will help you?

    http://support.advancedcustomfields.com/forums/topic/custom-image-size-with-image-field/

    I ended up having to use “Image ID” instead of URL, but the code posted there is exactly what I’m using.

    The only change would be to choose either true or false, for the image size code in the functions file, here:

    add_image_size( 'homepage-thumb', 97, 83, true );

    I have mine set to true so it doesn’t distort the image – check out this page in the WP docs, about “Crop Mode” :

    http://codex.wordpress.org/Function_Reference/add_image_size#Crop_Mode

    Hope that helps!

  • OH!! I found it.. Now I feel really stupid.

    I just had to change the Return Value on the image field to “Image ID” instead of using URL.

  • Maybe we can help each other on this one? I’ve been working on something similar with no luck.

    I got so far as creating a custom image size by adding something like this to the functions.php file:

    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'homepage-thumb', 97, 83, true ); /* 97px wide by 83px tall */
    }
    
    add_filter( 'image_size_names_choose', 'my_custom_sizes' );
    
    function my_custom_sizes( $sizes ) {
        return array_merge( $sizes, array(
            'homepage-thumb' => __('Homepage Thumbnail'),
        ) );
    }

    Replacing homepage-thumb with the name of your custom thumbnail size. Where it says “true” that just uses a soft proportional crop, instead of a hard crop. If you changed that to “false” it will create a new separate image file when you upload, rather than just resizing the original image to those proportions.

    The problem I’m having, is the code to use that image isn’t working. I can’t even get it to show the default thumbnail size. I tried using your code above, like this:

    <img src="<?php $homethumb = the_field('button_one_image'); echo $homethumb['sizes']['homepage-thumb']; ?>" />

    I don’t know what I’m doing wrong though, I must be missing something.

  • Kind of my point really, I’m not a programmer. I design custom templates, but I don’t do any custom coding. If there’s no example, I’m at a loss.

    oh well, I’m sure there’s someone out there that knows how to code php and uses ACF, I’ll check wp forums. Thanks anyway.

  • Thanks.

    What I’m having trouble with is the code to use. ACF code.

    Here’s what I tried that’s not working:

    <?php if ( get_post_meta($post->ID, 'my_image', true) ) : ?>
    <a href="<?php if ( get_post_meta($post->ID, 'my_image_link', true) ) : ?>"><img src="<?php the_field('my_image'); ?>" /></a>
    <?php endif; ?>

    This is what I’m having trouble with. When I add the ACF code to load the Taxonomy (which should be converted to a link, since the ACF Link field isn’t working for some reason) I’m not getting a real link, I’m getting a link to a number that goes nowhere.

  • Sorry, let me paste what I wrote up there:

    “there is no documentation for this particular thing here, no example code”

    What I mean is there’s no documentation for what I’m trying to accomplish. I did review the documentation that is available and tried using that to create a link to the category, as I mentioned in my original post:

    “I’ve tried messing with the Taxonomy Field (along with the Image field), but couldn’t get that to work as a link (image would link to a number, but it didn’t go anywhere).”

  • I’m sorry, I have no idea what you’re trying to tell me LOL!

    Does anyone have an answer to this one yet? It’s probably something simple, but I have no idea to go about it because there is no documentation for this particular thing here, no example code, nothing. I just need to know what code and what fields to use and I don’t have time for reading tutorials on the internet, I’m kind of on a tight schedule. If there was documentation for this stuff on this site, I wouldn’t be asking in the forums 😉

    Help Please?

    thanks..

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