positron-solutions / dslide

Present anything Emacs can do with programmable, extensible, configurable slides made from org mode headings
GNU General Public License v3.0
100 stars 2 forks source link

Images not shown if ATTR_ORG width is set #6

Closed jefftrull closed 4 weeks ago

jefftrull commented 2 months ago

If org-image-actual-width is set to nil users can provide a width attribute that will be used for image previews, permitting scaling to fit the text size etc. Unfortunately when this feature is used, dslide won't display the image at all.

Repro: use the attached code. Evaluate the setup code block at the end. Supply your own image under "Subheading with Image". Now try running dslide with and without the #+ATTR_ORG: width=50. You should see that the image only appears when the ATTR_ORG line is not present.

#+TITLE: Reproducing dslide image scale issue
#+AUTHOR: Jeff Trull

* First Heading
* Second Heading
words
** Subheading with Image
#+ATTR_ORG: width=50
[[some_image_here.png]]
* Third Heading

* Presentation Setup                                               :noexport:

#+begin_src elisp :results none
  (require 'org-bullets)
  (defun jet/dslide-setup ()
    (setq-local org-hide-emphasis-markers t)
    (org-bullets-mode 1)
    (text-scale-adjust 3)
    (visual-line-mode)
    ;; use my ATTR_ORG inline image size hints instead of the actual size
    (setq-local org-image-actual-width nil)
  )
  (add-hook 'dslide-start-hook #'jet/dslide-setup)
#+end_src
psionic-k commented 1 month ago

Sorry, didn't notice the email. Definitely a will-fix.

psionic-k commented 4 weeks ago

I should have read your example a little better.

You need to enable the action on that heading. Not every action is on by default. You can add dslide-image-action to dslide-default-actions to make it on by default, but it might act up on other link types.

* Subheading with Image
:PROPERTIES:
:DSLIDE_ACTIONS: dslide-action-image
:END:
#+ATTR_ORG: width=50
[[some_image_here.png]]

Re-open if I have neglected something else :space_invader:

jefftrull commented 4 weeks ago

But that doesn't explain why it works if I don't use ATTR_ORG, right? Without that the image shows up perfectly fine, no need for dslide-action-image.

jefftrull commented 4 weeks ago

I feel like the fact that dslide normally shows my images, even though I have set no image actions, suggests that this is a valid issue. dslide only fails to show them when I have set ATTR_ORG. So to me it seems unrelated to dslide actions.

It doesn't look like I have the power to reopen bugs in this repo, so I hope you will reconsider :)

psionic-k commented 4 weeks ago

I closed the issue because the reproduction is definitely missing an action. Without an action being used, whatever behavior we see is coincident to something else. Dslide won't touch the images if the action isn't running.

I'm not saying you're wrong that ideally nothing would change, but if there is a path of investigation that will lead somewhere, it's not straightforward, and the fix would be a workaround that doesn't do better than using an explicit action and also depends on some coincident external behavior remaining unchanged. Actions are the right way.

Under the hood, the image action will do basically the same thing as org-toggle-inline-images. This just lets us have bare links while editing but pretty images while presenting without remembering to toggle all the time.