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

Add plugin: ImageThumblinksPlugin #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add plugin: ImageThumblinksPlugin #259

wants to merge 1 commit into from

Conversation

dandersson
Copy link

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 ImageThumbnailsPlugin is 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 the meta.yaml, with file name matching and hard-coded dimensions, and then write something like:

[![My dog.]([[!!images/x300-img_0001.jpg]])]([[!!images/img_0001.jpg]])

in the markup to generate the link, remembering the specific prefix.

Plugin description

ImageThumblinksPlugin (note links vs nails) 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:

[[!thumblink|My dog.|x300|images/img_0001.jpg]]

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 TextlinksPlugin to 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

  1. I get error messages like

    17:52:33 hyde.server Cannot load file: [media/images/x300-img_0001.jpg]
    

    from hyde -v serve when 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 existing ImageThumbnailsPlugin class, 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.

  2. 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.

  3. This plugin must be loaded before TextlinksPlugin in 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

  1. Thumbnails are automatically generated, but not automatically removed if they are removed from the post. This is also true for 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 .thumbnail folder to the media path, though.
  2. There are more possible arguments for the thumbnail generating function that are not implemented in the ImageThumblinksPlugin syntax. 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.

@navilan
Copy link
Member

navilan commented Mar 19, 2014

@dandersson - Thanks for all this awesome work. I will get these merged in a couple of weeks.

@dandersson dandersson changed the title Add plugin: ImageThumbnailsPlugin Add plugin: ImageThumblinksPlugin Mar 19, 2014
@dandersson
Copy link
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.

@llonchj
Copy link
Contributor

llonchj commented May 23, 2015

Thanks @dandersson
Can you please write some unit tests so we can merge this plugin?

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

Successfully merging this pull request may close these issues.

None yet

3 participants