Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail files not being generated in 3.0 #89

Open
jeryj opened this issue Jul 26, 2019 · 0 comments
Open

Thumbnail files not being generated in 3.0 #89

jeryj opened this issue Jul 26, 2019 · 0 comments

Comments

@jeryj
Copy link
Contributor

jeryj commented Jul 26, 2019

After upgrading to 3.0, the "Keep WordPress Thumbnails" option no longer works. I've looked around at how to fix it, and I have a fix, but I'm not sure if my fix breaks another option, so I didn't want to put in a PR.

Basically, $this->keepThumbnails is used in in DynamicImagesTool->setup() before it's set by ImgixTool->setup().

The flow goes like:

DynamicImagesTool {
  setup() {
    if (!$this->keepThumbnails) {
            add_filter('wp_image_editors', function($editors) {
                array_unshift($editors, '\ILAB\MediaCloud\Tools\DynamicImages\DynamicImageEditor');

                return $editors;
            });
        }
   }
}

ImgixTool extends DynamicImagesTool {
   setup() {
      parent::setup();
     
       // keepThumbnails option is set _after_ the parent::setup(), so it's never set correctly to be used in parent::setup();
      $this->keepThumbnails = Environment::Option('mcloud-imgix-generate-thumbnails', null, true);
  }
}

So, the two fixes are:

  1. In ImgixTool(), Move $this->keepThumbnails = Environment::Option('mcloud-imgix-generate-thumbnails', null, true); above parent::setup(); Or
  2. Move the if (!$this->keepThumbnails) { ... } code from DynamicImagesTool()->setup() to after $this->keepThumbnails is set in ImgixTool()->setup().

I wasn't sure if one was better/worse than the other since I don't know the ins and outs of the plugin as well as you :) If it's easier for you, I'm happy to put in the PR for the best change if you let me know which one to go with (or some other one).

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

No branches or pull requests

1 participant