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

image.field_image is not needed anymore - and no images #3

Open
ehausen opened this issue Dec 20, 2018 · 9 comments
Open

image.field_image is not needed anymore - and no images #3

ehausen opened this issue Dec 20, 2018 · 9 comments
Assignees

Comments

@ehausen
Copy link

ehausen commented Dec 20, 2018

I just installed new local Contenta install and this repo and run both. Got error when loading the app.
Checking the network tab I found out that apparently image.field_image is not correct.

in home.ts I saw the comment
// @todo Remove image.field_image when JSON API bug is fixed.
and removed image.field_image from the line below so that it now is:
include: 'image,category,tags,image.imageFile'

The error went away, but now there is no images.
looking at the home.html image URL should come from {{ recipe.image.imageFile.url }} but no url field is returned, in my recent Contenta install.

How to fix this? Not familiar with Drupal as a api backend yet, even if Drupal is quite familiar.

@mortenson
Copy link
Member

@ehausen Thanks for the issue! I'm not sure what the issue is, I haven't worked in Ionic or Contenta in a long time. I'm looking at the closest project to this, contenta_angular, and it looks like they also reference field_image:

https://github.com/contentacms/contenta_angular/blob/2b3ea0338da05ad1cd655a3d12932382623fa707/src/app/services/backend.service.ts#L23

Maybe something in Contenta changed really recently?

@ehausen
Copy link
Author

ehausen commented Dec 20, 2018

Well the comment mentions when JSON API bug is fixed, so I guess that is that for the field_image.

I was just wondering did image.imageFile have the url sometime before, because now it's not there. But I guess that is the case and contenta default demo install possibly changed their data structure?

@mortenson
Copy link
Member

Maybe I could tag in @e0ipso for help here - are you aware of anything that's changed in the demo that would cause recipe images to stop working in the Ionic (and possibly Angular) demos? I was using the image.imageFile.url back when I first set this up, but maybe that's not a valid reference now.

@e0ipso
Copy link
Member

e0ipso commented Dec 20, 2018

Yes some changes happened since then. I'm fuzzy about whether or not the deployed version (frozen in the past) had those changes pushed or not.

@mortenson mortenson self-assigned this Dec 20, 2018
@ehausen
Copy link
Author

ehausen commented Dec 20, 2018

I'm able to get the file url with a separate request, but doesn't seem right I would need to query tha api once per image. Or am I supposed to do somekind of aggregates request to get the image URLs..

Just trying to learn the Contenta / Drupal-as-API-backend best practices.

Would also be good to get demos working because they represent the state of the project for newcomers. :)

@ehausen
Copy link
Author

ehausen commented Dec 20, 2018

in home.html
I get the images if I change
<img src="{{ recipe.image.imageFile.url }}">
to
<img src="http://127.0.0.1:8888{{ recipe.image.imageFile.uri.url }}">

So I was able to dig out the file url from imageFile.uri.url
but then also needed the file server site url.

Feels a bit awkward. How this should be done?

@mortenson
Copy link
Member

If that's the only nesting level in the JSON API response that lets you get to the URL, I guess that's the right way to do it. It does look weird though.

@ehausen
Copy link
Author

ehausen commented Dec 23, 2018

Would @e0ipso know if this looks correct, or is the right way to use Contenta? Of course putting site base URL in a variable would be more elegant

@e0ipso
Copy link
Member

e0ipso commented Dec 27, 2018

It looks correct to me.

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

3 participants