Bug #18204
closed3d Flipbook Lite
0%
Description
Hi All,
I believe the 3D Flipbook lite plugin is supposed to create an output like this: https://flipbooks.futuresinitiative.org/blog/
We have a group trying to use the plugin to create a flipbook pdf on the Commons on this site: https://cunyhumanitiesalliance.org/
When they try to upload their pdf they are getting an error, see screenshot.
I tried to recreate the error on my test site here: https://classtestbmcc.commons.gc.cuny.edu/2023/05/11/flipbook-post-test/
I could not re-create the same upload error. But even once the flipbook pdf is embedded in a post, the flipbook will still not display. It flashes as it loads and then disappears. I wonder if the Commons blocking of iframes is causing this error?
I am not sure about the other error, I have asked the user for more info on the pdf they are using.
Files
Related issues
Updated by Boone Gorges over 1 year ago
At a glance, it appears that the screenshotted error has to do with domain mapping. It would probably go away if you replaced 'cunyhumanitiesalliance.commons.gc.cuny.edu' in the source file URL with 'cunyhumanitiesalliance.org'.
As for the problem on https://classtestbmcc.commons.gc.cuny.edu/2023/05/11/flipbook-post-test/ - I am seeing the same behavior. But when I try embedding a flipbook on a different Commons site, it works as expected. I suspect that there's a plugin conflict. Perhaps you could try on another Commons site to see what you find?
Updated by Laurie Hurson over 1 year ago
Hi Boone,
I was granted access to the site and still cannot get it to work.
I changed the file url, see screenshot.
And i tested it on the site here: https://cunyhumanitiesalliance.org/?p=4091
Updated by Boone Gorges over 1 year ago
- Category name set to Domain Mapping
- Status changed from New to Reporter Feedback
- Assignee set to Boone Gorges
- Target version set to 2.1.7
It looks like you can change the URL, but after saving, it goes back to the old one. It's an interface quirk in the plugin.
Looking more deeply, it appears that the 3d flipbook plugin pulls up information about the source PDF in such a way that Mercator can't apply the mapped domain (technical note: it does get_post_meta( $post_id )
, which bypasses the necessary filter points). Luckily the plugin provides a filter that I was able to use to correct the incompatibility. See https://github.com/cuny-academic-commons/cac/commit/3797ae1b16a48425eb984b989ac692c1fbd9189d. Laurie, this change is live on production for you to verify.
Updated by Laurie Hurson over 1 year ago
Thanks so much for taking a look Boone.
I tested it on production and it appears to be working https://sitetest4.commons.gc.cuny.edu/2023/05/15/flip-test-1/
Just confirming this fix will also work on a mapped domain like https://cunyhumanitiesalliance.org/?
Updated by Boone Gorges over 1 year ago
Great! Yes, it should now work on mapped domains as well.
Updated by Laurie Hurson over 1 year ago
Hi Boone,
Tested this on the live site, and still seeing display issues:
https://cunyhumanitiesalliance.org/flipbook-test/
Maybe this fix isn't pushed to the live site yet? If not that is fine - will it go live in the 5/23 release?
Updated by Boone Gorges over 1 year ago
- Assignee changed from Boone Gorges to Jeremy Felt
The fix is deployed, but apparently there's some other issue causing the item not to load. (Previously, the Flipbook application wasn't loaded, while now it's loading, but it's not fetching the PDF.)
Unfortunately, I don't have the source for the 3d Flipbook plugin's JavaScript application. I un-uglified the compiled source but I'm afraid I don't have enough information to narrow down the issue. What I can say is that, in the case of other sites on the Commons where Flipbook is using, something in the application makes an XHR/AJAX request for the source PDF, while on https://cunyhumanitiesalliance.org/flipbook-test/ this request is never being fired. It's odd - if there were more cross-domain or CORS issues, it seems like it'd show up in the browser console.
Jeremy, could you have a look? You might have some experience here, and this could be a good way to try out your server access.
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.7 to 2.1.8
Updated by Jeremy Felt about 1 year ago
I configured a mapped domain locally with all of the same plugins activated and everything works as expected with the PDF file from https://cunyhumanitiesalliance.org/flipbook-test/. I've set a few breakpoints in the minified JS, but nothing obvious has popped out (there's a lot of JS).
I'm having trouble accessing log files, and I'd like to check for anything there before digging through the JS any further. We can chat about that on today's call.
For future reference: wp plugin list --status=active --url=https://cunyhumanitiesalliance.commons.gc.cuny.edu
returned:
+------------------------------------------------+--------+------------------------------+--------------+ | name | status | update | version | +------------------------------------------------+--------+------------------------------+--------------+ | interactive-3d-flipbook-powered-physics-engine | active | none | 1.15.2 | | add-category-to-pages | active | none | 1.2 | | authors | active | none | 2.4.8 | | category-posts | active | none | 4.9.15 | | category-sticky-post | active | none | 2.10.1 | | contact-form-7 | active | none | 5.7.6 | | custom-user-css | active | none | 0.2 | | google-docs-shortcode | active | version higher than expected | 0.5-bleeding | | imsanity | active | none | 2.8.2 | | inaccessibility-checker | active | none | 0.0.3 | | posts-in-page | active | none | 1.4.4 | | really-simple-breadcrumb | active | none | 1.0.2 | | shortcodes-ultimate | active | available | 5.12.11 | | table-of-contents-plus | active | none | 2302 | | text-to-speech-widget | active | none | 1.0 | | wp-accessibility | active | none | 2.0.1 | | wp-ms-request-membership | active | none | | +------------------------------------------------+--------+------------------------------+--------------+
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.8 to 2.1.9
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.9 to 2.1.10
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.10 to 2.1.11
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.11 to 2.1.12
Updated by Boone Gorges about 1 year ago
- Target version changed from 2.1.12 to 2.1.13
Updated by Boone Gorges 12 months ago
- Target version changed from 2.1.13 to 2.1.14
Updated by Laurie Hurson 11 months ago
Hi all,
Are there any updates on this? Do we think we can get it working? And if not, maybe we should go with another flipbook plugin?
An alternative might be to make it possible to embed issuu into the commons, which might be a workaround/alternative to another flipbook plugin. Example:
https://issuu.com/hostoscollege/docs/color_hyperlink_only_hos-8669_no18_10-21-22
Updated by Boone Gorges 11 months ago
Laurie, thanks for your patience and for the ping.
I think I've found the issue. When editing items in the 3d-flip-book post type, you use the Media Library to select the PDF to be used. At this time, the plugin uses the 'url' returned from the Media Library to fetch the PDF and store metadata about that PDF, which is in turn used when rendering on the front end. In the case of the cunyhumanitiesalliance.org site, this metadata hadn't been properly generated. Looking into why this might be the case, I noticed that the Media Library on mapped sites returned non-mapped versions of attachment URLs. So the URL reported by the media library was https://cunyhumanitiesalliance.commons.gc.cuny.edu/wp-content/blogs.dir/9457/files/2023/05/C21-showcase-test1.pdf
instead of https://cunyhumanitiesalliance.org/wp-content/blogs.dir/9457/files/2023/05/C21-showcase-test1.pdf
. This mismatch was causing the plugin's async fetch to fail, which is why the metadata was never fetched.
What I'm wondering is, what should our strategy be here? Temporarily, I have put a filter on 'wp_prepare_attachment_for_js' that forces the 'url' parameter to use the mapped domain. This seems to fix the immediate problem. But I am unsure about how broad of a fix is appropriate. For example, if I were instead to filter 'wp_get_attachment_url', then the mapped domain would be used in all places, on the front end as well as elsewhere in the Media Library (as in the 'sizes' array). Or, going up one level more, I could apply the filter somewhere in wp_upload_dir, to ensure that baseurl and url are always mapped-domain-specific. Mercator filters 'home_url', 'site_url', 'plugins_url', 'content_url', but wp_upload_dir()
uses the unfiltered WP_CONTENT_URL
constant. Why? Is this a mystery that we want to solve? My gut says that the most conservative fix is at wp_get_attachment_url()
, since then all URLs for attachments will be mapped consistently, yet this is a narrow enough fix that it won't have weird implications. But I would like thoughts from Ray and/or Jeremy about this.
Laurie, could you please test my production hotfix to verify that it's working now?
Updated by Boone Gorges 11 months ago
Previously on the Mercator attachment issue: https://redmine.gc.cuny.edu/issues/15767#note-3
Updated by Boone Gorges 11 months ago
- Target version changed from 2.1.14 to 2.1.15
Updated by Laurie Hurson 11 months ago
Hi Boone,
I can see the flipbook working on cdev but not on a mapped domain.
https://sitetest4.commons.gc.cuny.edu/
I can't reach the humanities alliance site on cdev. I have this in my terminal:
146.96.128.252 commons.gc.cuny.edu
146.96.128.252 sitetest4.commons.gc.cuny.edu
146.96.128.252 cunyhumanitiesalliance.commons.gc.cuny.edu
Where am I going wrong? Sorry for this question. Once I can get to the HA site on cdev I can check it out.
Thanks,
Laurie
Updated by Boone Gorges 11 months ago
Sorry for not clarifying. The hotfix is on the production site. Are you able to test there?
Updated by Laurie Hurson 11 months ago
Thanks, Boone.
This appears to be working now!
Updated by Boone Gorges 11 months ago
- Related to Support #15767: Site loading slowly added
Updated by Boone Gorges 11 months ago
- Status changed from Reporter Feedback to Resolved
Thanks for confirming!
Jeremy and Ray, I've put a filter in place that targets wp_get_attachment_url
on all mapped domains. This should mostly affect the Media Library, but might also affect the front end in certain themes or with certain plugins. I've looked through some other filters mentioned by Ray in #15767 but I've determined that either (a) they're not relevant to the current issue (such as the 'custom_header' filters) or (b) they're covered by the filter I've put in place (such as the building of srcset). See https://github.com/cuny-academic-commons/cac/commit/abeb832bbafb6b8ef88c5da9aac3355ebfe3d323. I've deployed this into production and confirmed that it fixes the current issue, so I'm going to run with it for a while and we'll see if we get similar reports, or reports of side effects.
Updated by Raymond Hoh 11 months ago
Thanks for looking into this, Boone.
Filtering 'wp_get_attachment_url'
seems to be the way to go for now.
As for:
Or, going up one level more, I could apply the filter somewhere in wp_upload_dir, to ensure that baseurl and url are always mapped-domain-specific. Mercator filters 'home_url', 'site_url', 'plugins_url', 'content_url', but wp_upload_dir() uses the unfiltered WP_CONTENT_URL constant. Why?
Perhaps filtering 'upload_dir' or the 'upload_dir_path' option might be better options?
But, yeah, I'm not sure why WP_CONTENT_URL
is used instead of content_url()
in _wp_upload_dir()
. I came across a WP Trac ticket talking about WP_CONTENT_URL
and content_url()
here: https://core.trac.wordpress.org/ticket/25650#comment:19
Updated by Boone Gorges 11 months ago
Thanks, Ray! I thought about upload_dir and friends, but the deeper we go into WP the more nervous I get about filtering. If the current, more targeted solution works, I'd prefer to leave it at that.