def middle_truncate(value, size):
    """
    Truncates a string to the given size placing the ellipsis in the middle.
    """
    size = int(size)
    if len(value) > size:
        if size > 3:
            start = (size - 3) / 2
            end = (size - 3) - start
            return value[:start] + u'\u2026' + value[-end:]
        else:
            return value[:size] + u'\u2026'
    else:
        return value