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

Images are not cached #396

Closed
dopeboy opened this issue Sep 28, 2018 · 6 comments
Closed

Images are not cached #396

dopeboy opened this issue Sep 28, 2018 · 6 comments

Comments

@dopeboy
Copy link

dopeboy commented Sep 28, 2018

I want to start with the comment that this is a fantastic tool. Thank you @mitya57 and others for all your effort on this.

I was using retext on a low data cap connection. I had an image in my markdown file and noticed it gets reloaded in full when I make an update (of any kind) to my markdown file. Is there a way to cache images? If not, would you be open to a PR for it?

@mitya57
Copy link
Member

mitya57 commented Sep 29, 2018

Currently the only way to cache image is to save it locally, which is what I recommend to do :)

I will be open to a pull request if the implementation is not too complex.

@dopeboy
Copy link
Author

dopeboy commented Sep 29, 2018

Thanks for the quick reply, mitya57. I think my use case might be worth still solving if the final content is going to remotely hosted e.g. on github.

I'll perform a quick analysis and draft up an approach. If it sounds reasonable to you, I'll proceed with a PR.

@dopeboy
Copy link
Author

dopeboy commented Oct 28, 2018

Here's a proposed approach. All of it refers to tab.py. Feedback is welcome.

  • In startPendingConversion(), take self.editBox.toPlainText() and scan for images (both in markdown and HTML) that have a remote URL. For each such image, download the image and save it into /tmp. In this text that is being send to be rendered, replace the remote URLs with local paths.

  • When the live preview is closed (can be closed manually or through closing the file), delete these files in /tmp.

  • In triggerPreviewUpdate(), take an optional parameter. Pass this optional parameter to startPendingConversion(). This optional parameter will be non-null when triggerPreviewUpdate() is invoked by a text change. This is useful because if the user updated their remotely hosted image, we want a way for them to force a deep refresh of the live preview so that their new image shows. Text changes shouldn't initiate that but, say, opening and closing the live preview area should.

@dopeboy
Copy link
Author

dopeboy commented Nov 9, 2018

Bump @mitya57

@mitya57
Copy link
Member

mitya57 commented Nov 9, 2018

Sorry for the delay. The approach looks good to me, feel free to proceed.

@mitya57
Copy link
Member

mitya57 commented Nov 12, 2019

This was fixed in 5c7b389 and confirmed in #409 (comment), so I am closing this issue.

@mitya57 mitya57 closed this as completed Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants