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

A case when image picker not being handled in CMS #253

Closed
jamestagal opened this issue Jan 8, 2023 · 3 comments
Closed

A case when image picker not being handled in CMS #253

jamestagal opened this issue Jan 8, 2023 · 3 comments

Comments

@jamestagal
Copy link
Sponsor

jamestagal commented Jan 8, 2023

Hi @jimafisk ,
I found a situation when the images picker in the CSM didn't work on images when the relative path such as assets/ is defined in the html as follows:

<img src="assets/{image.source}" alt="{image.alt}" class="img-fluid w-100">
  "image": {
        "source": "post-1.jpeg",
        "alt": "Students sitting on bean bags studying"
    },

See a short screen share video talking through the issue.
https://www.loom.com/share/5f9fbea4292a4fc0b21bf82668e766c2

Regards,
Ben

@jimafisk
Copy link
Member

jimafisk commented Jan 8, 2023

Hey @jamestagal, thanks for the video that's super helpful!

Only showing the image widget when prefixing the path with "assets" actually is by design. I agree with what you said at 1:07 that it's a cleaner approach to pull out the static parts of the path (like the "assets" prefix and ".jpeg" suffix) and put them in your template. The problem is that it doesn't give the "discoverable" aspect of the CMS enough context to figure out what type of default field widget to use based on the JSON content value. We look for a very specific pattern in order to avoid accidentally loading an image widget when you maybe were just trying to describe an image path in text.

The developer instinct to abstract away the common parts makes a lot of sense if the end user was editing the JSON directly (or markdown equivalent like other SSGs). Fortunately with Plenti, the end user experience editing these types of fields should generally be through the widget, so the path complexity shouldn't be apparent. Of course if the developer isn't aware of this convention, their site won't break, they just won't get the enhanced editing experience. In the future it would be nice if the schema override to add this widget was aware of original path convention and would allow you to still get the image widget to work with a shortened path.

@jamestagal
Copy link
Sponsor Author

Hi @jimafisk
All good. Yes I see the issue with the "discoverable" aspect of the CMS trying to figure out what type of field widget to use. So I think you have designed it to work effectively this way but is a point for developers to be aware of. So I might add a comment to the post from yesterday on the baseurls and link to this post as a reference. 😄

Cheers,
Ben

@jimafisk
Copy link
Member

jimafisk commented Jan 8, 2023

Sounds great @jamestagal, thanks for helping keep the documentation / announcements up-to-date!

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

2 participants