Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Integration to Google Cloud Storage does not work for images #13

Closed
perqa opened this issue Feb 13, 2014 · 3 comments
Closed

Integration to Google Cloud Storage does not work for images #13

perqa opened this issue Feb 13, 2014 · 3 comments

Comments

@perqa
Copy link

perqa commented Feb 13, 2014

  1. User interface
    Images don't scale correctly: always to quadratic dimensions, regardless of original aspect ratio or desired dimensions. Image URLs end with "s900", for example. I now have to pre-scale my images to what I think will be the most useful size and set the desired dimension to 0x0 px to leave them unscaled by appengine-wordpress-plugin. This involves modifying the theme I'm using.
    For example, in the the Customizr theme, there is a file named wp-content/themes/customizr/inc/class-fire-init.php in which image dimensions for the slider are set:
    $this -> slider_size = array('width' => 1170 , 'height' => 500, 'crop' => true );
    By default, appengine-wordpress-plugin will scale them to 1170x1170px. I tried setting width to zero, but to my surprise images were then scaled to 500x500px! So the plugin can read both width and height, but still ignores one of them to produce a square version of the image? Finally, I have set both width and height to zero, and uploaded pre-scaled images, and that works for the general case.
  2. Admin interface
    It is not possible to save any edited images from the admin interface. Instead of saving to Cloud Storage, it just fails. Running plugins like "Regenerate Thumbnails" does not work. Inserting images into posts the normal way gives the same scaling issue as described above for the user interface (always quadratic images). You have to switch to text mode and manually edit all links, or use the public version of the links and paste them in manually.
@perqa perqa closed this as completed Feb 13, 2014
@perqa perqa reopened this Feb 16, 2014
@youminkim
Copy link

I also found this issue in the featured image of the post.
The featured image is generated by dynamically resizing/cropping via Google Storage like this:

http://lh4.ggpht.com/wlXvkk2sYSBtNx91-VA_n3v8_ON0-_euVIjAyS4ioFajOo95ZY2vppZl8kupWR5NhQOtnxjiOOTXwnUJNGCqCpT0quU2Ql8=s1038-c

While *=sXX-c option just generates squared image, the featured image is always squared.

See

  • add_image_size( 'twentyfourteen-full-width', 1038, 576, true ); // in twentyfourteen theme

  • uploads.php in appengine-wordpress-plugin

    if (self::is_production()) {
        if ( ! is_null( $options['size'] ) ) {
            $url .= ( '=s' . $options['size'] );
            if ( $options['crop'] ) {
                $url .= '-c';
            }
        }
        else {
            $url .= '=s0';
        }
    }
    

I just commented out this line:

  • $url .= '-c';

but it means that I will not use crop any more. Do you have any idea to fix it?

@hostfully
Copy link

I may have a fix.

It looks like the storage is built using picasa syntax. This article discusses how to better control image dimensions and clipping.

My change was

if (self::is_production()) {
  if ( ! is_null( $options['size'] ) ) {
    if ($options['crop']) {
      // this will cause the image to be downsized, then clipped to fit our dimensions.
      $url .= '=w' . $size['width'] . "-h" . $size['height'] . "-p";
    } else {
      $url .= ('=s' . $options['size']);
    }
  }
  else {
    $url .= '=s0';
  }
}

It seems to be working really well, but I'd love to hear back if anyone else tries this.

@tmatsuo
Copy link
Contributor

tmatsuo commented Nov 23, 2016

Cleaning up the old issues, but please reopen if it's still relevant

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants