Gatsby: Images in wordpress content are not being saved in the static folder

Created on 8 May 2018  路  7Comments  路  Source: gatsbyjs/gatsby

I am using the gatsby-source-wordpress module and content is being pulled correctly, however images in ACF and in the content area of posts/pages are not being stored in the static folder. They are being referenced in the wp-content/uploads/xx/xx folder. Is there a setting or a flag I need to set? I can't seem to find the answer anywhere. I have tried to build the project but the same issue occurs.

question or discussion

All 7 comments

Hey @colmandesilva, there's a section on Image Processing in the gatsby-source-wordpress docs. Images in the content area aren't supported. It looks like your ACF fields need to be of Image or Gallery type.

hey @m-allanson - Life saver. Thanks mate. Very unfortunate that content images are not supported. For the time being I am using allWordpressWpMedia to get all images and replace the image src in the content string. Not ideal, but will have to do until a better solution comes out.

@colmandesilva Adding support for that directly in gatsby-source-wordpress would be great, if you are up for it!

@pieh For sure. Once I wrap up this project I'll take some time to find a good way to implement it to future users.

@colmandesilva Thanks for the info --- would you mind sharing your code that shows how you are replacing the image source in the content string? And are you still working on implementing this within the github repository? Thanks!

@lelandsmith I got pulled into another project and really didn't get a chance to move forward with this unfortunately. It's been a few months but I will try to dig up the code.

Get all images:

allWordpressWpMedia{ edges{ node{ source_url localFile{ childImageSharp{ sizes{ src } } } } } } }

Then loop through all img tags in the content and replace the images with references:

// Find all images in node for(var i=0; i < images.length; i++){ for(var j=0;j<$listOfStaticImages.length;j++){ if(images[i].src.indexOf($listOfStaticImages[j].node.source_url) > -1){ images[i].srcset = ""; images[i].src = $listOfStaticImages[j].node.localFile.childImageSharp.sizes.src; } } }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  路  3Comments

andykais picture andykais  路  3Comments

brandonmp picture brandonmp  路  3Comments

timbrandin picture timbrandin  路  3Comments

signalwerk picture signalwerk  路  3Comments