Support » Plugin: Advanced Custom Fields: Image Aspect Ratio Crop Field » Set a crop ratio for a field programmatically?

  • This plugin is great.

    I would like to have the image field’s crop ratio pre-populated by the theme.

    Any tips?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author joppuyo

    (@joppuyo)

    Hey, this plugin works a lot like the normal ACF image field, if you just set the field value to an id of an image, it should work.

    The only thing you are missing, in this case, is the option to re-crop the image since the meta field for the original image id is missing in the attachment but the user could always delete the image and select a new one.

    • This reply was modified 1 year, 3 months ago by joppuyo.
    Thread Starter dbrabyn

    (@dbrabyn)

    Hey,

    Missing word in your sentence and I’m not sure what you saying I’m afraid.

    Plugin Author joppuyo

    (@joppuyo)

    Ah, sorry, what I meant that if you have an ACF image crop field called my_image_field in your post type, you can just set that field to an id of an attachment, just like with the normal ACF image field and it’ll work.

    Plugin Author joppuyo

    (@joppuyo)

    In PHP this would be

    <?php
    $image_id = 123
    $post_id = 456
    update_field('my_image_field', $image_id, $post_id)
    • This reply was modified 1 year, 3 months ago by joppuyo.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Set a crop ratio for a field programmatically?’ is closed to new replies.