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 utility method to retrieve Thumbnail url for an entity #3

Open
BigRoy opened this issue Dec 10, 2019 · 3 comments
Open

Add utility method to retrieve Thumbnail url for an entity #3

BigRoy opened this issue Dec 10, 2019 · 3 comments

Comments

@BigRoy
Copy link
Member

BigRoy commented Dec 10, 2019

Issue

The ThumbnailBase label widget is relatively low level in that you have to pass it the required URL it needs to retrieve the thumbnail from using its load method.

Meaning getting a Thumbnail for a User is something like this:

# Load user thumbnail
thumbnail = ThumbnailBase()
thumbnail.setFixedWidth(75)
thumbnail.setFixedHeight(75)
thumbnail.load("pictures/thumbnails/persons/{0}.png".format(user["id"]))

The URL changes dependent on the type of entity you are working with making this slightly more involved, plus you'll need to know the URLs for the entities.

Approach

What if we would hide away these URLs and make it easily accessible through a get_thumbnail_url function.

Here's a quick prototype that has some parts unfinished:

def get_thumbnail_url(entity):
    """Get the related thumbnail for an entity"""
    
    entity_id = entity["id"]
    entity_type = entity["type"]
    if entity_type == "Person":
        return "pictures/thumbnails/persons/{0}.png".format(entity_id)
    elif entity_type == "Project":
        return "pictures/thumbnails/projects/{0}.png".format(entity_id)
    elif entity_type == "Shot" or entity_type == "Asset":
        # Get Main Preview
        preview_file_id = entity.get("preview_file_id")
        if not preview_file_id:
            return
        return "pictures/thumbnails/preview-files/{0}.png".format(preview_file_id)
    elif entity_type == "Task":
        # todo: get latest image content from Comments on Task?
        raise NotImplementedError("Not implemented.")

This way, if any of the URLs change on CG-Wire's API side we would only need to update this one function as opposed to all codebases using qtazu requiring to update the URLs in their code..

@frankrousseau
Copy link
Contributor

frankrousseau commented Dec 14, 2019

todo: get latest image content from Comments on Task?

I think it's an information we can add in Zou.

@BigRoy
Copy link
Member Author

BigRoy commented Dec 14, 2019

@frankrousseau awesome. Maybe gazu could also provide the utilitity function to fetch a thumbnail URL for an entity as described above? Or isn't it generic enough?

And it'd be perfect if it was possible to get the URL as opposed to just a download function, so that it's doable to download it in different ways, e.g. threaded.

@frankrousseau
Copy link
Contributor

Yes, it sounds better to have this function in gazu.

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