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

GCS URL isn't being set until image optimized #362

Closed
alimuzzaman opened this issue Mar 9, 2019 · 18 comments
Closed

GCS URL isn't being set until image optimized #362

alimuzzaman opened this issue Mar 9, 2019 · 18 comments

Comments

@alimuzzaman
Copy link
Contributor

https://wordpress.org/support/topic/new-media-items-not-updating-with-correct-url/

Affected compatibility: Imagify and Smush.

The sync is being done after Imagify complete the optimization. So we don't get GCS URL until the optimization is completed.

We previously solved it by syncing the full size image first then sync all sizes again when optimization completes.
But the issue in 2.2.4 arrived when we changed (in issue #359) how Imagify prevent the sync on image upload.

Now we have to make sure that Optimization plugins don't prevent when we try to upload full size image first.

We had to do this in this way for performance measure. Unless we would have to sync twice once after upload and again when image optimized.

@alimuzzaman
Copy link
Contributor Author

It also prevents the manual sync.

alimuzzaman pushed a commit that referenced this issue Mar 16, 2019
Now GCS url will be used but preview won't be available untill they optimize the image.
@alimuzzaman
Copy link
Contributor Author

alimuzzaman commented Mar 16, 2019

@ewsopp
Now GCS url will be used but preview won't be available until the image optimization is done.

So we have two option:

  1. We don't skip the sync on upload. We will have to sync twice, once on upload, another on when optimization done.
  2. We add a constant to choose whether to upload twice or performance. We can try to add a loading animation on the edit post page until the image is optimized and fully synced.

@antonkorotkov do you have any idea?

@antonkorotkov
Copy link
Contributor

I think this issue should be moved to the next milestone. @alimuzzaman Can you make sure your commits to this issue do not break anything or just revert them so that we can do a release safely. We need to do it today/tomorrow.

@antonkorotkov antonkorotkov modified the milestones: v2.2.5, v2.2.6 Mar 18, 2019
@alimuzzaman
Copy link
Contributor Author

@antonkorotkov
No it will not break anything.

@antonkorotkov
Copy link
Contributor

Ok, thanks

@alimuzzaman
Copy link
Contributor Author

@antonkorotkov Need help.

@antonkorotkov
Copy link
Contributor

Need help.

what exactly?

@alimuzzaman
Copy link
Contributor Author

Syncing in Stateless mode with image optimizer is a mess.

The normal process for sync in Stateless mode with image optimizer:

  1. Image get synced and deleted from the server.
  2. The image gets downloaded from GCS to the server for optimization.
  3. Again optimized image gets synced and deleted from the server.

With the use of wp_stateless_skip_add_media filter and sync full image first feature, we can skip step 1 but that creates a new problem. Optimizer takes some time to optimize the image. So when we insert a new image in edit post page image gets broken, because no other image size is available on GCS.

In the last commit, I tried to disable SKIP ADD MEDIA when uploading via edit post page. But that doesn't help at all.

@antonkorotkov
Copy link
Contributor

Does this problem exist in Stateless mode only?

@alimuzzaman
Copy link
Contributor Author

Didn't test in other modes, should be there also.

and sync full image first feature

It ensures that GCS URL gets inserted in the post.

@antonkorotkov
Copy link
Contributor

I don't understand this part: So when we insert a new image in edit post page image gets broken, because no other image size is available on GCS.

Why we insert a new image?

@alimuzzaman
Copy link
Contributor Author

Sorry not we the user.

@antonkorotkov
Copy link
Contributor

Ok, what can we really do with this?

@alimuzzaman
Copy link
Contributor Author

I think if you take a look you might have some idea.

@antonkorotkov
Copy link
Contributor

Ok, will try to look into it this week. Please, give me the instructions on how to setup optimization plugin and steps to reproduce the issue.

@alimuzzaman
Copy link
Contributor Author

Check with both released and develop-alim branch.

  1. Stateless Mode.
  2. Enable Smush plugin.
  3. Upload a new image from new/edit post page.
  4. Change Image Size from right side metabox.

image

@antonkorotkov
Copy link
Contributor

I don't have enough time to look into it. Moving to the next milestone.

@antonkorotkov antonkorotkov modified the milestones: v2.2.6, v2.2.7 Apr 4, 2019
alimuzzaman pushed a commit that referenced this issue Apr 7, 2019
alimuzzaman pushed a commit that referenced this issue May 3, 2019
Disabled lazy sync for Smush and Imagify plugin.
@alimuzzaman
Copy link
Contributor Author

I have disabled the lazy sync (skip_add_media).

So the workflow should be now:

  1. On upload sync to gcs.
  2. Before optimization download from GCS to server if image not exists.
  3. Sync again, with backup image.

So there won't be any problem because all image sizes will sync on upload and after optimization (twice).
Previously we skipped the step 1 for performance, what caused some problem.

alimuzzaman pushed a commit that referenced this issue May 3, 2019
Disabled lazy sync for Smush and Imagify plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants