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

Embedded Media is not cached properly #9

Open
lejeunerenard opened this issue Mar 9, 2017 · 19 comments
Open

Embedded Media is not cached properly #9

lejeunerenard opened this issue Mar 9, 2017 · 19 comments
Labels

Comments

@lejeunerenard
Copy link

lejeunerenard commented Mar 9, 2017

I am embedding related media in my requests for a custom post type. When I get a cached response, the media array (post._embedded['wp:featuredmedia']) contains a copy of the array of posts I just received ( minus the _embedded property on each of the elements ).

@frankblundt
Copy link

I am having the same issue

@airesvsg
Copy link
Owner

Hi,

I can't simulate this error, as I reported it here:
https://wordpress.org/support/topic/not-working-with-_embed/#post-8808911

Can someone send me the files used with a dump of the database?
airesvsg@gmail.com

Thanks

@zgordon
Copy link

zgordon commented Jun 26, 2017

This may help. I am having the same problem and was able to duplicate it on this site here https://wp-api.webhostingforstudents.com with the following data.

import files

It looks like instead of getting the correct embedded content (media or author) it is getting post data instead.

Without plugin:
screen shot 2017-06-26 at 12 12 37 am

With plugin:
screen shot 2017-06-26 at 12 13 13 am

@krestaino
Copy link

I'm encountering this issue too.

@bjentsch
Copy link

@airesvsg - in your video, the bug reported here is visible at 4:53, where you select the data inside the author field. Correct me if I'm wrong, but I think this is exactly the behaviour as described in this bug.

@scottjs
Copy link

scottjs commented Sep 1, 2017

I think I'm having the same issue, the non-cached response contains everything we need but the cached version is coming back different. We're relying on the _embed response containing "media_details" which lists all of the images sizes and paths to the images.

The non-cached response of one of our requests contains just 2000 lines or so of JSON, whereas the exact same request when cached comes back with 50,000+ lines of JSON which means the cached response actually takes 1.5 seconds longer than the non-cached version, all the nesting looks different and no longer contains "media_details" within the "wp:featuredmedia" block so our images stop working.

screen shot 2017-09-01 at 14 24 47

@crankeye
Copy link

I can verify we are also having the same issue.

@airesvsg airesvsg added the bug label Oct 9, 2017
@krestaino
Copy link

krestaino commented Nov 8, 2017

@airesvsg Any update on this? Would a database dump help?

@mjharper84
Copy link

I'm having this issue using Angular as a front end.

After caching I lose the author object/name and just get an id:
post._embedded.author[0].name <-- missing

And my featured media is a list of posts instead of the media data.

wpbug

Hope this is fixable, will be a useful plugin!

Thanks

@celandro
Copy link

celandro commented Dec 3, 2017

withcache.txt
withoutcache.txt

Exact same issue. This is an absolute blocker for me. Not having featured images is terrible.

@KSVQ
Copy link

KSVQ commented Dec 20, 2017

I can confirm,, ?_embed doesn't work, the embed object

"_embedded": { ... }

gets omitted from the json

@harrisrobin
Copy link

having this issue as well :(

@harrisrobin
Copy link

Ok so here is how i got around it. So far seems to work.
I installed the plugin : https://wordpress.org/plugins/better-rest-api-featured-images/

and simply ignored the _embed.

@davidgolden
Copy link

@harrisrobin's response above worked for me. Had the same issue but this was a viable workaround.

@airesvsg
Copy link
Owner

I'll rewrite my plugin in the next month and I'll fix it.

Thanks

@ahrberg
Copy link

ahrberg commented Aug 11, 2018

I´m currently testing to cache the full outgoing result in the rest_pre_echo_response hook and apply the cache in the rest_pre_dispatch hook. Seems to work. I also need to reset the $_GET['_embed'] = null; after applying the cache to the result to stop the embedded links to be dispatched since the embedded result is in the cached result already. If you like the solution I can make a PR. Sorry for my incorrect old reply, I deleted that one.

@jmikrut
Copy link

jmikrut commented Nov 19, 2018

Any update on this fix? Still able to replicate the issue.

@firefiesta
Copy link

@ahrberg Could you show your code?

@jffluis
Copy link

jffluis commented Mar 11, 2019

There is any solutions to this bug yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests