• This is totally driving me crazy!

    Many people state they use

    $images =& get_children( ‘post_type=attachment&post_mime_type=image&post_parent=’ . $post->ID );
    foreach( $images as $imageID => $imagePost )
    echo wp_get_attachment_image($imageID, ‘thumbnail’, false);

    and apparently it works great

    I personnally have

    foreach($myposts as $mypost)
    {
    $imgs =& get_children(‘post_parent=’.$mypost->ID.’&post_type=attachment&numberposts=1&post_mime_type=image’);
    if (empty($imgs))
    {
    echo ‘… default pic’;
    }
    else
    {
    foreach($imgs as $attachment_id => $img)
    {
    $image = wp_get_attachment_image_src($attachment_id, “thumbnail”, false);
    var_dump($image);
    […]
    }
    }
    }

    which is basically the same, but whatever parameter I send to wp_get_attachment_image_src as size (mostly “thumbnail” but it is said to be the default so I shouldn’t need to pass it), I ALWAYS get the original picture (not resized)!
    And I have checked, the resized picture exists, it is just not fetched
    Nobody else seems to have the same problem which is just so infuriating…
    I could do it by adding myself the dimensions to the result (from toto.jpg to toto234x104.jpg) as it was before (the site has just been upgraded from an older version) but I don’t understand why this wouldn’t work as nobody else reported this problem
    The previous version of the site had “iMax Width” and “Resize and Save”, I got rid of both of them, I tried to make a new article with an attached picture in case it was them storing the previous data in a different way, but it is exactly the same
    Anyone has an idea of what is wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Don’t know if this is the answer to your problem but wp_get_attachment_image( $post->ID, 'thumbnail' ) works fine for me. Note that I’m using $post->ID and not the image id.

    Thread Starter ejmana

    (@ejmana)

    I am really puzzled about what you say: the examples I have found in the forum all use attachmentID and not postID, as stated in the example in https://codex.www.ads-software.com/Function_Reference/get_children

    Anyway with your code

    foreach($myposts as $mypost)	{
    //$imgs = &get_children('post_parent='.$mypost->ID.'&post_type=attachment&numberposts=1&post_mime_type=image');
    $image = wp_get_attachment_image( $mypost->ID, 'thumbnail' );
    var_dump($image);die();
    }

    it doesn’t work at all: I get an empty string, and I have also tried wp_get_attachment_image_src and this time received false

    I commented and uncommented the get_children call in case it was interfering, no changes.

    There is actually one person who seems to have the same issue as me 4 months ago
    https://www.ads-software.com/support/topic/200462?replies=8 (WordPressChina)
    but nobody replied to him/her… But that means it’s not something due to the latest 2.8 then

    Yes, I get the same error on 2.7. It used to work before, so I am guess it may be conflicting with another plugin… ? Will let you know if I find something out.

    Hi! I recently get this error and I was able to fix it.

    The problem is that WordPress doesn’t really generate the thumbnails due a low memory limit: you can upload fully the original picture, but ajax crashes when it tries to generate thumbnails. I didn’t realized it until I explored the upload folder and the posts galleries.

    Simply put something like php_value memory_limit 128M inside the .htaccess, and regenerate the thumbnails (or upload all pics again).

    darkghosthunter

    (@darkghosthunter)

    BTW, this for using thru a Attachment Loop, not a content loop.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_get_attachment_image_src and related img functions not giving thumbnails’ is closed to new replies.