• Resolved awx2d

    (@awx2d)


    I’m using the following custom function to pull the first image out of all posts to display them in a gallery using timthumb.php to scale them;

    // Echo out Full Gallery
    function full_gallery() {
    	global $wpdb;
    	global $post;
    	$image = "";
    	$first_image = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_type = 'attachment' ORDER BY <code>post_date</code> ASC LIMIT 0,1");
    	if ($first_image) {
    	$image = urldecode($first_image[0]->guid);
    	echo $image;
    	}
    }

    The problem I am having is that every image that is added either by using the Media Library or via the post using “Insert into post” is not getting attached to the post ..

    The image is in the post and visible but the when I check the media library it shows the image as unattached, the result is that the function above cannot fine the image as it is not attached to the post in the database

Viewing 4 replies - 1 through 4 (of 4 total)
  • Same here using the latest version of WordPress mu (2.8.4a)

    Ok, got it:
    in wp_xxx_posts, the value post_parent is not update when you create a new post and insert directly a new image.

    If you add an image, create a new post and insert this image (from the library), this works …

    Someone to write a bug report? it’s late here in France

    We’ve been having the same issue and have found this to definitely be a WordPress bug.

    The solution (until a fix is implemented) is to create pages (or posts) first and THEN go back into them and add the images.

    – Tim

    Thread Starter awx2d

    (@awx2d)

    Solution is actually to ensure you enter a title for the post/page then select the main post area, then add your images. Works everytime!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Media LIbrary : Attached’ is closed to new replies.