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

Can't use thumbnail() with height only, and width set to None #794

Closed
relikd opened this issue Jul 12, 2020 · 5 comments
Closed

Can't use thumbnail() with height only, and width set to None #794

relikd opened this issue Jul 12, 2020 · 5 comments

Comments

@relikd
Copy link
Contributor

relikd commented Jul 12, 2020

According to the documentation the thumbnail function should support setting height ony. However, the build process complains that width is a required positional.

".../templates/blocks/image.html", line 4, in top-level template code
    <img src="{{ image.thumbnail(height=this.height)|url }}">
TypeError: thumbnail() missing 1 required positional argument: 'width'

Setting width to None does not work either:

File ".../site-packages/lektor/db.py", line 785, in thumbnail
    width = int(width)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

which is weird in itself, db.py line 785 points to a different line in master branch.

I'm using the latest 3.1.3 version installed just a few days ago.

@relikd
Copy link
Contributor Author

relikd commented Jul 12, 2020

Ah! v3.1.3 uses this instead:

def thumbnail(self, width, height=None, crop=False, quality=None):
        """Utility to create thumbnails."""
        width = int(width)
        if height is not None:
            height = int(height)
        return make_thumbnail(_require_ctx(self),
            self.attachment_filename, self.url_path,
            width=width, height=height, crop=crop, quality=quality)

I guess its already fixed but not released yet.
When can we approx expect the new version to be available?

@nixjdm
Copy link
Member

nixjdm commented Jul 12, 2020

Yes, the thumbnail API was changed quite a lot in the master branch and this issue shouldn't exist any longer. The next release is pending a few remaining items on our checklist, but I don't have an ETA for it. Just as soon as we can. In the meantime you may want to install from source with pip install -e .

@nixjdm nixjdm closed this as completed Jul 12, 2020
@runfalk
Copy link
Member

runfalk commented Jul 13, 2020

Remember that you need to generate the admin javascript files when installing from source if you plan to use the admin interface. If you don't the admin will not be accessible.

Provided you have the necessary dependencies you can generate them using make build-js.

@relikd
Copy link
Contributor Author

relikd commented Jul 13, 2020

@runfalk thanks for the info.
To the topic, I assume the documentation is generated from current master?
Does it make sence to show an API to the general public that isn't available yet?
I can find arguments for both sides and its something that should be considered.

@runfalk
Copy link
Member

runfalk commented Jul 13, 2020

We are currently doing work to have a "stable" and "nightly" branch (or similar) of the docs. The first PR that ties docs directly to the code is here: #787.

This is mainly a problem since there hasn't been a release in so long and I expect it to be less of a problem going forward.

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

3 participants