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

Any way to optimize images? #48

Closed
sethxd opened this issue Apr 4, 2019 · 3 comments
Closed

Any way to optimize images? #48

sethxd opened this issue Apr 4, 2019 · 3 comments

Comments

@sethxd
Copy link

sethxd commented Apr 4, 2019

I'm struggling to figure out a way to optimize images. I believe I can't use gatsby-image because the images are stored remotely in Ghost. I might be able to use gatsby-image for the featured images if I use gatsby-plugin-remote-images first, because I can find those in GraphQL, but I'm not sure how to write the query for that.

Does anyone have experience doing this who could offer me some guidance?

@aileen
Copy link
Member

aileen commented Apr 5, 2019

This starter is using the gatsby-source-ghost plugin, which fetches the data from Ghost using its Content API. I don't believe it's possible to optimise all received images, but there's a feature request for that over here.

If you're looking on how to use the gatsby-plugin-remote-images in your queries and the examples listed in their docs are not helpful enough, I recommend going there to seek help.

You can also check out the Gatsby.js community, or - for Ghost specific questions - head over to our forum, where you'd be able to reach more people with this question.

@aileen aileen closed this as completed Apr 5, 2019
@MarioHdpz
Copy link

@sethxd
I'm also using the gatsby-source-ghost and the gatsby-plugin-remote-images cause I have Ghost in a localserver.

After adding the gatsby-plugin-remote-images to the gatsby configuration you have to add to the new tag to the correspondent nodes in utils/fragment.js

For example, if you left the default name property in the remote plugin (localImage) your fragment should look like:

    fragment GhostTagFields on GhostTag {
        slug
        name
        visibility
        feature_image
        localImage { publicURL }
        description
        meta_title
        meta_description
    }

This also goes for all the nodes where you gonna use the images: GhostPost, GhostPage, etc

Then you can query that localImages as <img src={ post.localImage.publicURL } alt={ post.title } />

Now you have the images locally and you can focus in the task of optimizing as you do with a Gatsby local image.

@sethxd
Copy link
Author

sethxd commented Apr 30, 2019

Thanks @MarioHdpz, I'll have to try that.

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