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

Configuration troubles #310

Closed
acespace90 opened this issue Jan 17, 2022 · 14 comments
Closed

Configuration troubles #310

acespace90 opened this issue Jan 17, 2022 · 14 comments
Labels

Comments

@acespace90
Copy link

acespace90 commented Jan 17, 2022

Question

Hi, I'm struggling with configuration. I've just installed the plugin in its Trial version. I'm following this guide https://nystudio107.com/docs/image-optimize/using.html but when I create an OptimizedImages I have no possibilities to add to an Asset Volume despite I have it.

Moreover I can't delete or add variants. Can you help me?

Screenshot 2022-01-17 at 13 21 15

@khalwat
Copy link
Contributor

khalwat commented Jan 17, 2022

What is happening is the JavaScript to create the new field settings is being executed before the script that implements Craft.OptimizedImagesInput() has been run.

I'm investigating.

khalwat pushed a commit to nystudio107/craft-plugin-vite that referenced this issue Jan 17, 2022
khalwat pushed a commit to nystudio107/craft-vite that referenced this issue Jan 17, 2022
khalwat pushed a commit that referenced this issue Jan 17, 2022
…y, causing the Settings to not appear correctly ([#310](#310))
@khalwat
Copy link
Contributor

khalwat commented Jan 17, 2022

Alright, so this was a fun one. Essentially what was happening is the JavaScript to create the ImageOptimize field settings was firing before the JavaScript module was loaded, causing an error in the JavaScript console, and nothing to appear on the page.

To fix this, I added an onload event fired by the Vite-generated script here:

craft-plugin-vite: nystudio107/craft-plugin-vite@bd1ef76#diff-7822397b9bf7419a9ceef3efa170cb314b92846a18348b54a8c68760f0830d67R131

...which allows me to add a listener that gets notified when the script is loaded, after which I can execute the necessary JavaScript:

craft-imageoptimize: 4b06c3a#diff-10becf48966b4b8d388ebb845637b040fcb6b0944f096964543566fd2003741cR328

Documented here: https://nystudio107.com/docs/vite/#script-onload-events

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-imageoptimize": "dev-develop as 1.6.41”,

Then do a composer clear-cache && composer update

lmk how you go

@khalwat khalwat closed this as completed Jan 17, 2022
@khalwat
Copy link
Contributor

khalwat commented Jan 17, 2022

I pushed a fix for the above that should fix an issue where the event was firing before the listener was even installed, in some cases (it’s async, so you never know)

Doing this again should pull down the latest:

    "nystudio107/craft-imageoptimize": "dev-develop as 1.6.41”,

Then do a composer clear-cache && composer update

lmk how you go

@khalwat
Copy link
Contributor

khalwat commented Jan 17, 2022

@acespace90
Copy link
Author

Hi thank you so much for the investigation, but I'm still having the same problem. I can't add the field to an Asset volume.

I ran composer clear-cache && composer update and updated to 1.6.41

This is what I have in my composer.json

"nystudio107/craft-imageoptimize": "1.6.41"

Screenshot 2022-01-18 at 11 04 26

@khalwat
Copy link
Contributor

khalwat commented Jan 18, 2022

This screenshot doesn't really show me anything -- can you scroll down and how me the problem area?

@acespace90
Copy link
Author

Sure. The point is that I can't see these fields (image taken from the doc)

image-optimize-field-volumes d23823f9

This is the entire page screenshot.

screencapture-localhost-18080-admin-settings-fields-new-2022-01-18-15_15_31

And of course when I go to an Entry this is what I have.

Screenshot 2022-01-18 at 15 19 51

By the way, am I the one that is having this problem?

@khalwat
Copy link
Contributor

khalwat commented Jan 18, 2022

Okay, so that screenshot looks right to me. I think I'm not clearly understanding the problem you've having?

If you create the field, and then go to Settings -> Assets are you unable to drag the Optimized Images field to an asset volume's field layout?

@acespace90
Copy link
Author

Okay, I'm probably doing something wrong. I'm not sure I understand then how to configure the field correctly.

What I did was create the OptimizedImages field into Settings ->Fields , but I can't figure out how to associate it to an asset volume.
Can you please explain to me step by step?

At some point I expect to do this as the doc says. But how?

image-optimize-field-volumes d23823f9

@khalwat
Copy link
Contributor

khalwat commented Jan 18, 2022

After you have created the Optimized Images field, go to:

Settings -> Assets then click on an Asset Volume, and then scroll down to add the field to the Asset Volume's field layout:

Screen Shot 2022-01-18 at 9 35 49 AM

@acespace90
Copy link
Author

Ok thank you, now I understand and I see all the variants of an image.

How do then I upload image in an Entry on Craft?

@khalwat
Copy link
Contributor

khalwat commented Jan 18, 2022

You just upload it as you normally would, and if it is in asset volume that has an Optimized Images field added to the field layout, it'll automatically generate all of the image variants for that image.

@acespace90
Copy link
Author

Right!
Thank you so much for your patience and sorry if I wasted your time

@khalwat
Copy link
Contributor

khalwat commented Jan 18, 2022

Not at all, that's what I'm here for! No worries.

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

No branches or pull requests

2 participants