Error image

This topic contains 2 replies, has 2 voices, and was last updated by jonadeis jonadeis 9 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3414
    jonadeis
    jonadeis
    Participant

    I created another search box, in “image options/primary image source”, I selected custom field and in “Custom field containing the image” I typed imagen_de_publicacion, i created the field with advanced custom field pro, but when it shows the results, the image doesn’t appear, and in the console it shows this error Resource interpreted as Image but transferred with MIME type text/html: “http://www.afsdp.org.pe/leguia-la-historia-oculta/610/”..

    I noticed that in “Available public custom fields types”, the “imagen_de_publicacion” field appears, so i would like your help.

    Thanks in advance

    #3416
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    This sounds like the image field does not actually contains the image url, but something else. The MIME type error indicates that the browser interpeted it as text, which usually means, that the image url is incorrect.

    Moreover the url “http://www.afsdp.org.pe/leguia-la-historia-oculta/610/” is definitely not an image url, it just points to one of your pages.

    After diggin up some old tickets I found a similar issue solved for someone. The ACF actually does not store the image url, but the image ID. Thus you need some post-processing function in order to make it work.
    This is what solved the issue for him. Put the following code into your themes functions.php file:

    
    add_filter( "asp_result_image_after_prostproc", "asp_cf_image", 1, 1 );
      
    function asp_cf_image( $image ) {
      if ($image != "" && strlen($image) < 10) {
        $atts = wp_get_attachment_image_src( $image );
        if (isset($atts[0]))
          return $atts[0];
        return null;
      }
      return $image;
    }
    
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #3426
    jonadeis
    jonadeis
    Participant

    thank you very much, the problem is solved

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

You must be logged in to reply to this topic.