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

Error phphtmlparser\dom #1

Closed
JohnMica opened this issue May 25, 2016 · 13 comments
Closed

Error phphtmlparser\dom #1

JohnMica opened this issue May 25, 2016 · 13 comments
Assignees
Labels
Milestone

Comments

@JohnMica
Copy link

Hi there.
It seems that once enabling these plugins there is an error causing the website to stop working. I opened an issue on grav thinking is the system but as soon as I disabled your plugins (both image plugins) the site is back to normal.
Error is getgrav/grav#849
Hope this helps with further development

@OleVik OleVik added the bug label May 28, 2016
@OleVik
Copy link
Owner

OleVik commented May 28, 2016

It will, thank you for raising the issue. This can be traced to this plugin, that is ImgSrcset, as ImgCaptions does not use a DOMParser. Would you mind sharing your imgsrcset.yaml-file, or are you using the plugins defaults? Also, were you able to locate the error in PHP's error_log?

@OleVik OleVik self-assigned this May 28, 2016
@JohnMica
Copy link
Author

Hi it's the default settings with only the plugin activated. Link is here https://www.dropbox.com/sh/ikoab3neb3n8yr7/AABghDaSecY0-3J7pw5veiN1a?dl=0

@OleVik
Copy link
Owner

OleVik commented May 29, 2016

The settings and plugin-files are all correct. Could you share a copy of your user-directory and potentially PHP's error_log? The plugin has been tested on both version 5.6 and 7 of PHP, so the version should not be an issue.

@JohnMica
Copy link
Author

Here goes the link for the whole site
https://www.dropbox.com/sh/0udjvi217if75w8/AAB4wznbMLJcepADkoO987dWa?dl=0

Hope this helps. Not sure where the Php log file is. System is using Php 7 live and both 5.6.x &7 local. Error appears on both versions.

@OleVik
Copy link
Owner

OleVik commented May 29, 2016

I did some debugging using your files as base, could you try setting twig_first in system.yaml to true? It is located in the pages-options, like this:

pages:
  twig_first: true

In your options it was set to false, and it appears that this might be a requirement of the plugin.

@JohnMica
Copy link
Author

JohnMica commented May 29, 2016

changed the twig - no more errors from the parse, however the front page is no longer loading the photos, css or markdown properly as per the photo attached.
cache cleared

twig first - activated
captura de ecran din 2016 05 29 la 17 56 09

twig first - false
captura de ecran din 2016 05 29 la 18 03 06

so leaving twig first is not an option yet for me. I am using the modular.twig with slider, text and hopefully in the near future the contact/subscribe respective modulars.

@OleVik
Copy link
Owner

OleVik commented May 29, 2016

This is unrelated to twig_first and the plugin itself. As per the errors, they are letting you know that the images cannot be found, which is because they do not exist where they are expected. How have you specified the image?

The plugin only does the following:

  1. Accesses processed Markdown.
  2. Finds img-elements.
  3. Uses the src-attribute to generate a srcset-attribute based on the widths specified.
  4. Sets the sizes-attribute based on the sizes specified.
  5. Returns the changed content for further processing by Grav.

So, for example with an image named street.jpg the content of a page's folder would look like this (with default widths):

page.md
street.jpg
street-320.jpg
street-480.jpg
street-640.jpg
street-960.jpg
street-1280.jpg
street-1600.jpg
street-1920.jpg
street-2240.jpg

@JohnMica
Copy link
Author

captura de ecran din 2016 05 29 la 19 42 10

images are placed in each section's folder but when twig_first and imgsrcset are active the errors regarding the images appear. when twig_first - false then images are found and rendered. As you can see the images are actually in their specified folder/route but only in the original size.

should i delete all images and then add them again ? would this have anything to do with the errors ?
captura de ecran din 2016 05 29 la 19 49 14

@OleVik
Copy link
Owner

OleVik commented May 29, 2016

The source image appears to be there, but not the sizes that the browser requests. The difference here is that the 404 error revealed by the Developer Console tells us that it is not the plugin or Grav itself, but rather that the images sought after actually do not exist. Thus twig_first is a required condition of the plugin, as Twig must be rendered before other effects are applied upon the Markdown-source.

From your example image, of the folder and file hierarchy, I do not see a file named Canabis1-320.jpg, Canabis1-480.jpg, etc. Note, that the plugin does not generate these images for your. It is simply an alternative way of using such images, generated by other means than Grav.

Your second example, of the Developer Console output, shows that the plugin is having the desired effect: It generates and applies the srcset- and sizes-attributes. For an example of how to generate these images, see this gist.

@OleVik OleVik closed this as completed May 29, 2016
@OleVik OleVik added this to the 1.1.0 milestone May 29, 2016
@JohnMica
Copy link
Author

I must have understood that it will automatically create such images names 320, 940 , etc...

This will explain the error not finding the images.
However the markdown is not interpreted when twig_first true ... Could be a grav bug then?

@OleVik
Copy link
Owner

OleVik commented May 29, 2016

That should not be the case. From the documentation:

Process Twig First

twig_first: false

If set to true Twig processing will occur before any Markdown processing. This can be particularly useful if your twig generates markdown that needs to be available in order to be processed by the Markdown compiler. One thing to note, if have cache_enable: false and twig_first: true page caching is effectively disabled.

Effectively, it tells Grav that Twig should be processed before Markdown. My guess is that this also processes things like special_chars, which would not allow manipulation of the DOM on the processed Markdown because the code is no longer valid.

@JohnMica
Copy link
Author

Thanks Ole for all the info. One more thing, rendering of the page changes when twig first. But I have taken another look and also the page CSS seems a bit broken where the button is no longer placed under the whole text positioned centre. If you check the live site canabismedical.ro you will see the difference in layout (live site has twig first false) where the local development (images sent so far) has twig first true/.

@JohnMica
Copy link
Author

Good luck with further development and hopefully in the near future the little issue will disappear :)

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

2 participants