Add plugin: ImageThumblinksPlugin#259
Open
dandersson wants to merge 1 commit intohyde:masterfrom
dandersson:ImageThumblinksPlugin
Open
Add plugin: ImageThumblinksPlugin#259dandersson wants to merge 1 commit intohyde:masterfrom dandersson:ImageThumblinksPlugin
dandersson wants to merge 1 commit intohyde:masterfrom
dandersson:ImageThumblinksPlugin
Conversation
Member
|
@dandersson - Thanks for all this awesome work. I will get these merged in a couple of weeks. |
Author
|
I noted that I had managed to write "Add ImageThumbnailsPlugin" (which is the name of the existing plugin) and not "Add ImageThumblinksPlugin" in the original commit message after all... Since I guess no one has pulled the branch yet, I forcefully updated the branch in this pull request to fix the commit message. Purely cosmetic, but less confusing. Is someone pulled, they can rebase to get the new commit message into history, or ignore it and keep the typo. |
Contributor
|
Thanks @dandersson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin rationale
When using other static content generating platforms, I found that I often used available constructs to generate thumbnail links to full size images on-the-fly from within posts. The facility for generating thumbnails in Hyde via
ImageThumbnailsPluginis quite static in that it must be defined in the configuration files external from the blog posts. Also, to generate a linked thumbnail pointing towards a full size image, one would at first need to define the thumbnail generating configuration in themeta.yaml, with file name matching and hard-coded dimensions, and then write something like:in the markup to generate the link, remembering the specific prefix.
Plugin description
ImageThumblinksPlugin(notelinksvsnails) enables a direct syntax for generating thumbnails from within the document. After the plugin is enabled in the site configuration, a line like this in the markup:will automatically generate the thumbnail itself during site generation using existing functions (parameters in the above example will be: width undefined, height 300 pixels; see the existing
ImageThumbnailsPlugin.thumb()for information on the parameters) and create the link of the earlier mentioned form.It does not clash with any existing functions to my knowledge. It needs to be loaded before
TextlinksPluginto work, though.The code is almost over-the-top documented with inline comments, since I find that looking at the code is of great use until the Hyde documentation in general gets major updates.
Lingering issues
I get error messages like
from
hyde -v servewhen loading any of the thumbnails generated from this plugin. However, the images load fine in the browser. The thumbnail creation is handled fully by the functions in the existingImageThumbnailsPluginclass, and those images do not give the error message. I have not been able to find the problem. As it does not affect the actual generation or the serving, I'm guessing it is some meta registration of resources that is not done correctly, for some reason.I do not know if the markup syntax clashes with other plugins, or if there is a more natural syntax that should be followed by convention.
This plugin must be loaded before
TextlinksPluginin order for that plugin to post-process the generated syntax. Perhaps this could be solved by explicitly calling that plugin from within this one, but enforcing a plugin load order as right now might be clearer.Possible enhancements
ImageThumbnailsPlugin, and is perhaps not an actual issue. Cleaning out the thumbnail folder manually solves this in a simple way. There might be use cases where one would not want to remove the thumbnail even if it is not referenced in any local posts, e.g. for external hotlinking purposes. This would be easily solved by moving the image from the.thumbnailfolder to themediapath, though.ImageThumblinksPluginsyntax. They could be added without problem, but I personally can not really see a use case for them, and if they were to be added, it would be good to know if the current parameter syntax was OK beforehand.