readme.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Requirements
  2. ------------
  3. * pip install pillow beautifulsoup4
  4. Summary
  5. ===========
  6. This plug-in:
  7. - Adds a `style="width: ???px; height: auto;"` attribute to any `<img>` tags in the content, by checking
  8. the dimensions of the image file and adding the appropriate `style="width: ???px; height: auto;"` to the `<img>` tag.
  9. - Also finds any `div class="figures"` tags in the content, that contain images and adds the same style to them too.
  10. - If RESPONSIVE_IMAGES setting is true, it adds `style="width: ???px; max-width: 100%; height: auto;"` instead.
  11. - Corrects Alt text: If an img alt attribute = the image filename, it sets it to ""
  12. Assuming that the image is 250px wide, it turns output like this:
  13. <div class="figure">
  14. <img alt="/static/images/image.jpg" src="/static/images/image.jpg" />
  15. <p class="caption">
  16. This is the caption of the figure.
  17. </p>
  18. <div class="legend">
  19. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  20. tempor incididunt ut labore et dolore magna aliqua.
  21. </div>
  22. </div>
  23. into output like this:
  24. <div class="figure" style="width: 250px; height: auto;">
  25. <img style="width: 250px; height: auto;" alt="" src="/static/images/image.jpg" />
  26. <p class="caption">
  27. This is the caption of the figure.
  28. </p>
  29. <div class="legend">
  30. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  31. tempor incididunt ut labore et dolore magna aliqua.
  32. </div>
  33. </div>
  34. or this, if RESPONSIVE_IMAGES = True:
  35. <div class="figure" style="width: 250px; max-width: 100%; height: auto;">
  36. <img style="width: 250px; max-width: 100%; height: auto;" alt="" src="/static/images/image.jpg" />
  37. <p class="caption">
  38. This is the caption of the figure.
  39. </p>
  40. <div class="legend">
  41. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  42. tempor incididunt ut labore et dolore magna aliqua.
  43. </div>
  44. </div>