<s> from django . template import Library <EOL> try : <EOL> from sorl . thumbnail . templatetags . thumbnail import thumbnail as sorl_thumb <EOL> SORL = True <EOL> except Exception : <EOL> SORL = False <EOL> try : <EOL> from easy_thumbnails . templatetags . thumbnail import thumbnail as easy_thumb <EOL> EASY = True <EOL> except Exception : <EOL> EASY = False <EOL> register = Library ( ) <EOL> def thumbnail ( parser , token ) : <EOL> '''<STR_LIT>''' <EOL> thumb = None <EOL> if SORL : <EOL> try : <EOL> thumb = sorl_thumb ( parser , token ) <EOL> except Exception : <EOL> thumb = False <EOL> if EASY and not thumb : <EOL> thumb = easy_thumb ( parser , token ) <EOL> return thumb <EOL> register . tag ( thumbnail ) </s>
