import pywikibot
from pywikibot import pagegenerators
from IPython.display import Image
from IPython.core.display import HTML

site = pywikibot.Site('commons', 'commons')
cat = pywikibot.Category(site, 'Category:salad')
gen = pagegenerators.CategorizedPageGenerator(cat)

print("begin")
for page in gen:
    url = page.get_file_url()
    if url.lower().endswith(".jpg"):
        display(Image(url,width=100, height=100))
    else:
        print(url)
print("done")