Exemplo n.º 1
0
def create_image():
    image_file = make_image()
    master_image = MasterImage(master=ContentFile(image_file.read(),
                                                  'test-image.png'),
                               alternate_text='test')
    master_image.save()

    return master_image
Exemplo n.º 2
0
def create_image():
    image_file = make_image()
    master_image = MasterImage(
        master=ContentFile(image_file.read(), 'test-image.png'),
        alternate_text='test'
    )
    master_image.save()

    return master_image
Exemplo n.º 3
0
def make_master_image(path, legacy_path, alternate_text):
    image_path = os.path.join(path, '..', legacy_path)
    image_path = os.path.normpath(image_path)

    with open(image_path, 'rb') as img:
        master_image = MasterImage(
            alternate_text=alternate_text
        )
        master_image.master.save(os.path.basename(legacy_path), File(img))
        master_image.save()

    return master_image