Support » Plugin: WP QuickLaTeX » Locally cached formula images are generated but don’t load

  • I’ve installed the QuickLaTeX plugin in my academic WordPress homepage. The plugin works fine with local caching deactivated. However, if I activate it, the formulas are no longer rendered – they appear in Mozilla Firefox as if I were just displaying the LaTeX code (but without the math delimiters) in the text. Loading the site with Google Chrome shows a broken image icon next to each unrendered formula (I reckon the latter must be the image caption).

    Some data on my problem:

    – I have WP Super Cache installed, active and working.
    – My WordPress version is 5.1.4 and the server’s PHP version is 5.2.10 – pretty old, I know, but the server admins won’t be able to update it for a while for technical reasons, it’s beyond my control. In any case, I’ve installed version 3.8.3 of the QuickLaTeX plugin, which is supposed to work with the above versions of WordPress and PHP.
    – The ql-cache subfolder of the wp-content folder has been created with the appropriate permissions and the cached images of the formulas (.svg and .png with the “auto” option) are being properly generated and saved in this folder. Just in case, I’ve opened each of the cached image files and they look as they should.
    – When running in debug mode, no LaTeX errors appear in the page (nor should they, given that the images are being correctly generated and the site works just fine with local caching disabled).
    – I’ve also tried to delete all contents in the ql-cache subfolder and reload the page so the formula images are regenerated. Indeed the latter is successfully done, but the loading problem persists.

    It seems that QuickLaTeX (or WordPress itself) is unable to read the images in the ql-cache folder, which is strange given that they’re able to generate them and save them there.

    The list of files and subfolders in my wp-content folder and the list of files in the ql-cache subfolder follow below, with the respective ownerships and permissions.

    
    sh-3.2$ ls -al
    total 80
    drwxrwsr-x+  7 apache apache 4096 Apr 15 20:16 .
    drwxrwsr-x+  7 apache apache 4096 Apr 15 16:57 ..
    -rwxrwsr-x+  1 apache apache 1129 Apr 14 19:27 advanced-cache.php
    drwxrwsr-x+  5 apache apache 4096 Apr 15 16:57 cache
    -rwxrwsr-x+  1 apache apache   28 Apr  2 20:28 index.php
    drwxrwsr-x+ 13 apache apache 4096 Apr 15 16:34 plugins
    drwxrwsr-x+  2 apache apache 4096 Apr 15 17:02 ql-cache
    drwxrwsr-x+  7 apache apache 4096 Apr  2 21:08 themes
    drwxrwsr-x+  3 apache apache 4096 Apr 15 10:49 uploads
    -rw-------+  1 apache apache 3798 Apr 15 16:21 wp-cache-config.php
    -sh-3.2$ cd ql-cache
    -sh-3.2$ ls -al
    total 88
    drwxrwsr-x+ 2 apache apache 4096 Apr 15 17:02 .
    drwxrwsr-x+ 7 apache apache 4096 Apr 15 20:16 ..
    -rw-rw-r--+ 1 apache apache  501 Apr 15 17:02 quicklatex.com-9b875220881fcf73b90745c03f93b81d_l3.png
    -rw-rw-r--+ 1 apache apache 2126 Apr 15 17:02 quicklatex.com-9b875220881fcf73b90745c03f93b81d_l3.svg
    -rw-rw-r--+ 1 apache apache   84 Apr 15 17:02 quicklatex.com-9b875220881fcf73b90745c03f93b81d_l3.txt
    -rw-rw-r--+ 1 apache apache  511 Apr 15 17:02 quicklatex.com-dc9b3797fac4cc9cb3bdac50689655c5_l3.png
    -rw-rw-r--+ 1 apache apache 2211 Apr 15 17:02 quicklatex.com-dc9b3797fac4cc9cb3bdac50689655c5_l3.svg
    -rw-rw-r--+ 1 apache apache   84 Apr 15 17:02 quicklatex.com-dc9b3797fac4cc9cb3bdac50689655c5_l3.txt
    -rw-rw-r--+ 1 apache apache  454 Apr 15 17:02 quicklatex.com-f6336c3c451bed01ef67bbe7e4b67cd5_l3.png
    -rw-rw-r--+ 1 apache apache 1051 Apr 15 17:02 quicklatex.com-f6336c3c451bed01ef67bbe7e4b67cd5_l3.svg
    -rw-rw-r--+ 1 apache apache   84 Apr 15 17:02 quicklatex.com-f6336c3c451bed01ef67bbe7e4b67cd5_l3.txt
    -sh-3.2$ 
    

    As one can see, the server (user apache) has permission to both read and write the image files in the ql-cache folder.

    What should I do? The site gets considerably slower with local caching disabled and I’m concerned abut the fact that QuickLaTeX server’s policy is to block the IP of sites with cache continuously disabled for at least six months, which will also prevent the formulas from being rendered. This is not a problem yet since I’m starting to use the plugin now, but it will become so in the future.

    • This topic was modified 7 months, 2 weeks ago by lqpman.
    • This topic was modified 7 months, 2 weeks ago by lqpman. Reason: Small grammar fixes
    • This topic was modified 7 months, 2 weeks ago by lqpman.
    • This topic was modified 7 months, 2 weeks ago by lqpman. Reason: Added attempted workaround
    • This topic was modified 7 months, 2 weeks ago by lqpman.
    • This topic was modified 7 months, 2 weeks ago by lqpman.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author advanpix

    (@advanpix)

    This has nothing to do with QuickLaTeX plugin.
    Please be sure to disable the “Photon” feature in Jetpack. It adds garbage to every URL pointing to image. That prevents images to be shown properly.

    Thanks for the reply. However, I don’t have the Jetpack plugin installed, so the cause must be something else. In fact, should I have the Jetpack plugin installed in my case? I’ve got word that only high-traffic sites need to bother with it. If so, I need to figure out which version of Jetpack is compatible with my versions of WordPress (5.1.4) and PHP (5.2.10), particularly the latter since, as I said above, my server’s admins won’t be able to update it in the near future – according to Jetpack’s changelog, the latest such version seems to be 7.3.2.

    Moreover, I have (.svg, .png and .jpg) images in this and other pages in my site, and they are loading normally with QuickLaTeX’s local cache enabled. Only the QuickLaTeX formula images are being affected.

    By the way, I don’t know if it’s related, but the CDN support is disabled for my site.

    • This reply was modified 7 months, 2 weeks ago by lqpman. Reason: Added explanation
    • This reply was modified 7 months, 2 weeks ago by lqpman.
    • This reply was modified 7 months, 2 weeks ago by lqpman.
    • This reply was modified 7 months, 2 weeks ago by lqpman.

    In due time, @advanpix: I’ve used Firefox’s HTML inspector to check the HTML code of the page and see whether your hypothesis about the formula images’ URL’s being scrambled by something is true. In fact , it’s not: the URL’s not only match precisely the name and location of the formula image files on the ql-cache subfolder, but also if I copy the URL’s to a separate tab and load them alone, the browser is able to load the images normally. Only when the formula images’ URL’s are embedded into the page code as they are does the loading fail.

    This also reinforces my impression that the problem is not permission-related.

    • This reply was modified 7 months, 2 weeks ago by lqpman.
    Plugin Author advanpix

    (@advanpix)

    Then it is caused by theme or one of other plugins (most likely based on JavaScript).
    For example, what is “svg-support” plugin is doing? Most likely it messes the images

    Hi there,
    I’m the developer of the plugin SVG Support (I got a ping because of the mention).

    Just to chime in here, my plugin adds the ability to upload SVG files to use in WordPress like any other image.

    It also has extra functionality to allow you to render the SVG inline if you choose to. Without activating advanced features, it’s simply a mime type filter to allow SVG uploads.

    Not sure if this helps in this case, but may help clear up what the plugin does and how that may affect you.

    Hmm, that’s odd. If I force the locally cached formula images to be saved in .png format, the page indeed loads normally.

    According to the official plugin description, the SVG Support plugin “uploads SVG files to the Media Library and render SVG files inline for direct styling/animation of an SVG’s internal elements using CSS/JS.” More details can be found at the WordPress plugin’s page – or, even better, from the plugin creator @benbodhi’s comment above (kudos!). I was using it (version 2.3.15) for ensuring proper rendering of SVG images in this and other pages in my site as it’s done for other (bitmap) image formats – or at least I thought so.

    It turned out that the only two images (in another page) of my site which I believed to be in .svg format were in fact in .png format. I tried to load a proper .svg image for testing purposes in that page, with no success. Deactivating the SVG support plugin changed nothing – no .svg images were rendered at all. After I reactivated the SVG support plugin and played with its advanced settings, forcing inline SVG brought the rendering of .svg images back, as suggested in the SVG Support plugin’s FAQ. However, this only works if I deliberately set QuickLaTeX to save the formula images in .svg format. If I leave it in “Auto”, the formula images no longer render again – probably some JS/CSS script is getting messed up due to the interaction between the QuickLaTeX and the SVG Support plugins in this case.

    I could of course simply leave it configured for saving formula images in .svg format, but that may hinder site compatibility with older browsers; leaving in .png format instead, on its turn, brings up the typical scaling problems bitmap images have. I reckon that the “auto” format allows the browser to choose the best option for itself.

    In view of that, since my site (with the current versions of WordPress and PHP) cannot render SVG images without some sort of plugin, is there some other WordPress plugin for rendering SVG images which you recommend for use with QuickLaTeX (with a version working with my versions of WP and PHP)?

    P.S.: curiously, the size of the inline formulas is different, depending on whether you render them in .png or .svg format – the latter keeps the inline formulas at rigorously the same size as the text font, whereas the former gets the inline formulas slightly larger.

    • This reply was modified 7 months, 2 weeks ago by lqpman.
    • This reply was modified 7 months, 2 weeks ago by lqpman.
    • This reply was modified 7 months, 2 weeks ago by lqpman.
    Plugin Author advanpix

    (@advanpix)

    Well, have you cleared the caches in WP-SuperCache after playing with SVG support options? Maybe it is other plugin – I don’t know. But this is definitely has nothing to do with WP-QuickLaTeX itself. Something is messing around with links to SVG files, generated by WP-QuickLaTeX.

    Try switching off plugins one by one, clear caches of WP-SuperCache (and other optimizing plugins) – and check if SVG is shown correctly.

    • This reply was modified 7 months, 2 weeks ago by advanpix.

    I’ve cleared both the WP Super Cache and QuickLaTeX caches, and deactivated all my WordPress plugins except SVG Support, QuickLaTeX and WP Super Cache. The problem remains – if I leave the saving format setting for QuickLaTeX formula image files as “Auto” no formulas are rendered. Setting this back to either “PNG” or “SVG” brings back the formulas (with the above P.S. proviso that the scaling of the formulas differ from each other in those cases).

    Finally, if I deactivate the SVG Support plugin as well, the formulas are no longer rendered with the “Auto” and even with the “SVG” option, so the SVG Support plugin (with inline SVG rendering active, since these are all inline formulas) or another WordPress plugin with the same functionality is absolutely needed. Only the “PNG” option works in this case. I took care of deleting all caches before doing this as well.

    That still left the possibility that the problem is caused by my theme (Fashionistas). I’ve tried to switch the theme to something more canonical like Twenty Nineteen or Twenty Seventeen (considering my WordPress version, it’s a good idea to be conservative) and clear all caches once again, but the problem remains the same.

    • This reply was modified 7 months, 2 weeks ago by lqpman.
    • This reply was modified 7 months, 2 weeks ago by lqpman.

    Make sure you are using the latest version of SVG Support. You may be on one that was stripping meta from attachments. The current version doesn’t do that and should still work fine in your setup (wow, that PHP is old). It may be that… long shot, but all I can think of really.

    Outside that, I don’t know if I’ll be much help. Using my plugin in the simplest form, with no settings activated should just allow you to use SVG like any other image. But there may be media library functions that process the files in the library that don’t process SVG well, because it isn’t supported in core at all.

    I haven’t used WP QuickLaTeX, but I could potentially try them together and see if I can reproduce the issue… Let me know how you go.

    @benbodhi Thanks for your reply. Unfortunately, my current version of the SVG Support plugin (2.3.15) is the latest one compatible with my version of PHP (5.2.10 – ikr?), so updating it is not an option until the server admins are able to update PHP as well. There’s nothing I can do about that at the moment – I even tried to ignore the PHP version guidelines and update the SVG Support plugin anyway, but the new version chokes with the syntax and parsing changes in PHP from version 5.6 onwards as compared to 5.2. Moreover, the only option currently active for the SVG Support plugin is inline rendering, since, as I said above, I cannot do without it if I want to use SVG.

    I’ve also noticed another problem: I’m starting to use slightly more complicated LaTeX code in another page of my site. If I enforce formula image file format to be SVG, several (but not all) the formulas there get scrambled – some don’t render at all, others become filled with gibberish or are strangely cropped, and some others are rendered normally. I guess that with simple enough formulas (as in the page linked in the OP) the problem doesn’t show up in all its g(l)ory. The only way to get all formulas correctly rendered is to use PNG instead, with the associated scaling penalty which is inherent of bitmaps and the longer loading times in the first access (albeit only then, thanks to local caching).

    Anyhow, I think I’ve reached the limit of what I can do about the problem at the moment, and my lectures resume tomorrow. For that I need my site functional, so I think I’ll leave QuickLaTeX set to render formula images in PNG format for the time being and visit this thread from time to time to check whether some answer has been found or not. Thanks to all for all the help, though!

    • This reply was modified 7 months, 1 week ago by lqpman.
    • This reply was modified 7 months, 1 week ago by lqpman.

    You definitely have a pretty complex situation.

    It’s a shame you can’t just upgrade your hosting! I’m sure that would alleviate a number of issues.

    I’ll try to make some time to test my plugin with QuickLaTeX and see how I go.

    Yes, it’s a shame indeed. Changing hosts for my site is not an option either – my site is currently hosted at my University’s server which hosts the professors’ academic webpages, and I have almost ten years of content there.

    I simply cannot afford to pay on my own (in fact, I don’t even know if I’m allowed) to outsource the hosting to another, paid WordPress server (so I’m able to use plugins) just to get a newer PHP version, not to mention the work and time needed (which I don’t have) to migrate even just the parts of my site which are essential to my current teaching.

    Thanks again!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Locally cached formula images are generated but don’t load’ is closed to new replies.