syamilmj / Aqua-Resizer

Resize WordPress images on the fly
502 stars 205 forks source link

AquaResizer does not work #35

Closed biyanpasau closed 11 years ago

biyanpasau commented 11 years ago

Guys,

I'm having issue with this script. It does not work on some site. This site, i work with, using subdomain. Here the site: http://babybook.bg/blog/

I'm using this function:


    function get_first_image() {
        global $post;
        $id = get_post_thumbnail_id();
        $imgurl = wp_get_attachment_image_src($id, 'large');
        $thumbs = get_children(array (
            'post_parent' => $post->ID,
            'post_type' => 'attachment',
            'numberposts' => 1,
            'post_status' => null,
            'post_mime_type' => 'image',
        ));

```
    if (has_post_thumbnail()) { // check for featured image
        $id = get_post_thumbnail_id();
        $imgurl = wp_get_attachment_image_src($id, 'large');
        $imgurl = $imgurl[0];
    } elseif ($thumbs) { // if no featured image, go with attached images
        foreach ($thumbs as $thumb) {
            $img = wp_get_attachment_image_src($thumb->ID, 'large');
            $imgurl = $img[0];
        }
    }
    return $imgurl;
}

// Credit to Aqua Resizer by Syamil MJ
function image_attachment($key, $width, $height, $crop) {
    global $post;
    $img_url = get_first_image(); //get full URL to image (use "large" or "medium" if the images too big)
    $image = aq_resize( $img_url, $width, $height, $crop ); //resize & crop the image

    if($image) {
        echo '<img src="'.$image.'" alt="Thumbnail_zero_attch"/>';
    }
    else { //else, return
        return;
    }
}
```

And this is how I echo the image
<?php $img_url = get_first_image(); $image = aq_resize( $img_url, 240, 'auto', false ); if($image) : ?>

<?php echo '<img src="'.$image.'" alt="thumbnail_3rika"/>'; ?>

<?php endif; ?>
--- Tried with this also (example 1), https://github.com/syamilmj/Aqua-Resizer/wiki/Examples, but it does not work. So i believe this is not the function issue. All image is attached properly, btw. But what make it weird is, it works on some post, old post actually. But when I try creating a new one, it does not work at all. --- I have updated the script to the latest version and issue persist. The theme is installed in so many sites, but only two of them that can not run this script properly.
biyanpasau commented 11 years ago

Nevermind, found the solution already :+1:

mxmzb commented 11 years ago

Okay. :)

krishna19 commented 10 years ago

@biyanpasau i'm also need for that script, can you share the script