Closed henrywangnl closed 3 years ago
is the source of your post public? it'd help me to see index.Rmd and index.md.
This is how I included an external image in an example post
thanks, I made a suggestion there.
to be clear, I need to make the Xpat query less strict, but I like the idea that there's a bug when there's no alternative text :stuck_out_tongue_winking_eye:
hmmm, it didn't seem change: https://henrywang.nl/rmarkdown-wordpress-goodpress/
I'll look into it shortly
I knitted Rmd and got the image https://rmd-wordpress.eu/rmarkdown-wordpress-goodpress/ (don't worry I'll remove your post from my website ;-) )
I'll know try without alt text.
even without alt text I get the image https://rmd-wordpress.eu/rmarkdown-wordpress-goodpress/, weird.
it's especially weird to me that it works for the other plot in your post on your blog!
Can you please look in your WordPress gallery (from the dasbhoard) to see whether wp.png is there?
Can you please look in your WordPress gallery (from the dasbhoard) to see whether wp.png is there?
yes, it's there lol
as wp.png, right, not the old name?
at least it got uploaded, the bug must be after that
yes, it's wp.png
: https://henrywang.nl/wp-content/uploads/2020/06/wp.png
weird, I'm still thinking about what can have gone wrong. btw can you update goodpress, and re-run wp_post()?
I re-install it but it didn't work.
I tried to upload a new image and it works now...
but the ggplot2 plot disappeared?
yes, ggplot2 plots work
oh no, even ggplot2 plots don't show anymore haha
I think something is wrong with the file path handler, which works weird...
So locally you still have the plots in the figs folder but they don't get uploaded to the gallery?
So locally you still have the plots in the figs folder but they don't get uploaded to the gallery?
Yes, the plots are still there. I'm not sure if they are uploaded to WP every time I call wp_post
but I can see they are in galley.
how about you delete them from the gallery manually and rerun the function?
haha let me try
they are uploaded to gallery successfully but didn't show correctly in the post.
mmmh can you replace post_folder
with the correct path and run
post_folder <- "inst/post-example3"
file.create(file.path(post_folder, "index.html"))
withr::with_dir(
post_folder,
rmarkdown::pandoc_convert(
"index.md",
to = "html",
output = "index.html",
wd = getwd(),
options = "--mathjax"
)
)
content <- xml2::read_html(file.path(post_folder, "index.html"))
imgs <- xml2::xml_find_all(content, "//img")
imgs
this is to check the XPat query.
here is what I get:
{xml_nodeset (2)}
[1] <img src="figs/unnamed-chunk-3-1.png" width="700px" style="display: block; margin: auto;">
[2] <img src="figs/wp.png" width="700px" style="display: block; margin: auto;">
Argh so the Xpat query works. I'm sorry, I'm a bit puzzled.
I think what I'd try is
(yeah sorry that's what you get for being an early tester/adopter of the package: all the problems)
No worries! I did learn a lot from the discussion!
I think what I'd try is
As you see from my blog, the steps you suggest work now! Yet I have no idea what happened haha!
argh yeah sometimes one needs to resort to some version of "let's try turning it off an on again" or "delete everything and starts again" :sweat_smile: I'm very relieved it worked!!
I don't see what we can add to the docs so I'll close this. :-)
Hi Maelle,
It seems that this issue appears again even I tried the steps you suggested last time. Could you please check it for me? My post: https://henrywang.nl/roc-curve-simulation-classification-performance/ Post source: https://github.com/henrywangnl/Blog/tree/master/20200714 Thanks!
I fixed it by changing the image URLs on the WordPress Dashboard for the time being, so now the post looks fine...
Argh, sorry I don't have time to dive into this at the moment (which is also why I took so long to respond).
I see there are .DS_store
files that aren't needed, but I don't think they can be the bug source (worth trying to delete them and then adding .DS_store
to .gitignore
).
It's of course especially problematic since adding the images via the dashboard sounds painful!
If you feel like having a look yourself see
https://github.com/maelle/goodpress/blob/d53850cf194fe94a831e4070c4866f0dae923b8e/R/post.R#L142-L160
and
https://github.com/maelle/goodpress/blob/d53850cf194fe94a831e4070c4866f0dae923b8e/R/post.R#L219-L245
what's also important to investigate is
are the images uploaded to WordPress?
or is the problem "only" that their URL isn't changed in the content that's sent to the API?
A last wild guess for today, apart from deleting .DS_store
can you also try not using underscores in filenames? Who knows. Sorry for not being more helpful.
Regarding this issue, the images not shown properly are those generated by r chunk codes as the images urls in the post are linked to the folder of figs
not to the wordpress dashboard url.
Hi @maelle
I think this issue might because of the following code but I didn't verify it yet, so just to give you an idea:
As media
is a data frame with two columns, length(media)
and seq_along(media)
may not what you want here. They will only loop the first two images. I guess you mean !is.null()
or nrow()
or something.
https://github.com/maelle/goodpress/blob/d53850cf194fe94a831e4070c4866f0dae923b8e/R/post.R#L151-L162
Would you want to try & make a PR?
Sure Maelle! I'll try it.
Thanks Henry
On Mon, Oct 26, 2020, 6:45 AM Maëlle Salmon notifications@github.com wrote:
Would you want to try & make a PR?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maelle/goodpress/issues/22#issuecomment-716318279, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7BXKHVPP67VFDBD2R3OKTSMUEILANCNFSM4OJJT6GA .
for example, one image links to this path: https://henrywang.nl/rmarkdown-wordpress-goodpress/figs/wp.png