# Change the image of the UV/image editor with python for 2.8

i want to change the active image of my uv/editor with codes, i dont know how to do this in 2.8

could someone help ?

Try this:

import bpy

for area in bpy.context.screen.areas:
if area.type == 'IMAGE_EDITOR':
area.spaces.active.image = bpy.data.images['Your_image_name']


Deactivate image in Image Editor

for area in bpy.context.screen.areas:
if area.type == 'IMAGE_EDITOR':
area.spaces.active.image = None


I needed this to work even if Image Editor is in different window so I used an additional loop for Bleneder windows:

import bpy