Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi!

    Well, the best way is to make a filter function to access the results after post processing, but right before displaying.

    I’ve put together a sample code, but since I’m not familiar with the exact structure of the array of images, you will need to finish that part:

    add_filter('asl_result_image_after_prostproc', 'asl_image_from_cf_array', 1, 2);
    function asl_image_from_cf_array($img_url, $post_id) {
    
      $meta = get_post_meta($post_id, "imagem", true);
      if ( is_array($meta) && count($meta)>0 ) {
         /**
          * This is where you need to get the image from the array
          * based on it's structure.
          *
          * For example:
          *    $img_url = $meta[0];
          * or:
          *    $img_url = $meta['image'];
          * or where the image exatly is.
          */
      }
    
      return $img_url;
    }
    Thread Starter cyberoma

    (@cyberoma)

    Very nice, worked perfectly, look the code final:

    add_filter('asl_result_image_after_prostproc', 'asl_image_from_cf_array', 1, 2);
    function asl_image_from_cf_array($img_url, $post_id) {
        $img = get_field('imagem', $post_id);
    
        if ( is_array($img) && count($img) > 0 ) {
            $img_url = $img['sizes']['thumbnail'];
        }
    
        return $img_url;
    }

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Localize images from Advanced Custom Fields’ is closed to new replies.