def factor_size(value, factor):
    """
    Factors the given thumbnail size. Understands both absolute dimensions
    and percentages.
    """
    if type(value) is int:
        size = value * factor
        return str(size) if size else ''

    if value[-1] == '%':
        value = int(value[:-1])
        return '{0}%'.format(value * factor)

    size = int(value) * factor
    return str(size) if size else ''