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

Default ATTR_ORG attribute #80

Closed
azzamsa opened this issue Sep 22, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@azzamsa
Copy link
Contributor

commented Sep 22, 2018

Hi abo-abo.

-- Preface --
I am going to make simple twitter clone. I love documenting my thought with embedded picture alongside word. So I thought it will be nice to have such thing. But I find that I can use 'inline-image' in org buffer. Wow that nice I said. With the support of 'org-download' it will be lot of fun. Take picture here and there and yank it right away (using org-download various ways). Awesome tool :)

-- main issue --
Images taken from screenshot tools (e.g scrot) sometimes had big width. Especially in big screen. Yanking those picture right away in org buffer using org-download-yank cause infinite blinking in my emacs. Until I hit 'ENTER'. Furthermore the image will have enormous width.

I can solve this by adding #+ATTR_ORG: :width 650 But it takes more step. Adding the attribute then reopen the buffer (reload doesn't work for me).

What if we have default image attribute that we can specify in custom value ?

This is my temporary hack. But works for me.

(funcall org-download-annotate-function link)
    "\n"
    (format "#+ATTR_ORG: :width 650")
    "\n"
    (if (= org-download-image-html-width 0)
        ""
      (format "#+attr_html: :width %dpx\n" org-download-image-html-width))

in

There are attr_html and attr_latex but both doesn't mentioned in readme.

Thank you for nice pakace :)

@abo-abo abo-abo closed this in 07b98eb Sep 25, 2018

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 25, 2018

Please see if the new org-download-image-org-width does what you want.

There are attr_html and attr_latex but both doesn't mentioned in readme.

They are visible via customize-group org-download.

Thank you for nice pakace :)

You're welcome.

@azzamsa

This comment has been minimized.

Copy link
Contributor Author

commented Sep 26, 2018

Thanks. It works well.

I add some addition (maybe there is cleaner way for the branching condition). I don't know if this useful for upstream.

(defun org-download-insert-link (link filename)
  (if (looking-back "^[ \t]+" (line-beginning-position))
      (delete-region (match-beginning 0) (match-end 0))
    (newline))
  (insert
   (concat
    (funcall org-download-annotate-function link)
    "\n"
    (if (= org-download-image-html-width 0)
        ""
      (format "#+attr_html: :width %dpx\n" org-download-image-html-width))
    (if (= org-download-image-latex-width 0)
        ""
      (format "#+attr_latex: :width %dcm\n" org-download-image-latex-width))
    (if (and (= org-download-image-org-width 0)
             (= org-download-image-org-height 0))
        "")
    (if (and (/= org-download-image-org-width 0)
             (= org-download-image-org-height 0))
        (format "#+attr_org: :width %dpx\n" org-download-image-org-width))
    (if (and (= org-download-image-org-width 0)
             (/= org-download-image-org-height 0))
        (format "#+attr_org: :height %dpx\n" org-download-image-org-height))
    (if (and (/= org-download-image-org-width 0)
             (/= org-download-image-org-height 0))
        (format "#+attr_org: :width %dpx :height %dpx\n" org-download-image-org-width
                org-download-image-org-height))
    (format org-download-link-format
            (org-link-escape
             (file-relative-name filename (file-name-directory (buffer-name)))))))
  (org-display-inline-images))

Result

width only

#+attr_org: :width 650px
[[file:2018-09-25-18:36:22_2018-09-26_07-14-40.png]]

both of them

#+attr_org: :width 650px :height 300px
[[file:2018-09-25-18:36:22_2018-09-26_07-19-51.png]]

height only

#+attr_org: :height 300px
[[file:2018-09-25-18:36:22_2018-09-26_07-21-25.png]]

none of them

[[file:2018-09-25-18:36:22_2018-09-26_07-22-43.png]]
@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 27, 2018

What is org-download-image-org-height?

@azzamsa

This comment has been minimized.

Copy link
Contributor Author

commented Sep 27, 2018

It just to add :height to #+attr_org. I don't find :height mentioned in org docs. But I don't know. It works for me.

@azzamsa

This comment has been minimized.

Copy link
Contributor Author

commented Sep 30, 2018

Oh no. :width already enough to shrink image height and width. Sorry my bad.

@abo-abo

This comment has been minimized.

Copy link
Owner

commented Sep 30, 2018

No problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.