Home>Support>Image attachments don’t get detected

Image attachments don’t get detected

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

This simple code snippet is detecting the first image attached to the post:

$images = get_posts(
            	array(
                	'post_type'      => 'attachment',
                	'post_mime_type' => 'image',
                	'post_parent'    => $post->ID,
                	'posts_per_page' => 1,
          		  )
      		 	 );?>
		wp_get_attachment_image($images[0]->ID );

It works on any post, except those with a page-builder structure. It seems that Page Builder hides the attached image from the function wp_get _attachment_image

Any tip?

Thanks

Fabio

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 10 years, 6 months ago Andrew Misplon
    Hi, I Work Here

    Hi Fabio

    Thanks for reaching out.

    I’ll ask Greg or Braam if they can attend to this ASAP.

  2. 10 years, 6 months ago Fabio Marzocca

    Hi Misplon,

    I discovered my code was wrong. Now it is working!

    Thank you for you cooperation.

    Fabio

  3. 10 years, 6 months ago Andrew Misplon
    Hi, I Work Here

    Awesome, really glad to hear you made progress here.

    It might not be related but Braam was going to suggest the following:

    Maybe double check that the images you’re trying to find are definitely attached to the posts in which you’re trying to find them. An image can be inserted into a post without being attached to that post. In other words, if you uploaded the image while editing the post with a Page Builder layout, it will be attached to that post. If it was previously uploaded elsewhere it will not be attached to the Page Builder post.

    I’m just pasting that for information sake.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More