# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.db.models import Q
-from django.http import HttpResponseRedirect
+from django.http import HttpResponseRedirect, HttpResponseNotFound
from django.views.generic import ListView, DetailView
from sorl.thumbnail import get_thumbnail
model = Sound
def get(self, *args, **kwargs):
- im = get_thumbnail(self.get_object().channel.image_url, '300x300', crop='center')
+ image_url = self.get_object().image_url or self.get_object().channel.image_url
+ if not image_url:
+ return HttpResponseNotFound()
+ im = get_thumbnail(image_url, '300x300', crop='center')
return HttpResponseRedirect(im.url)
sound_image = SoundImage.as_view()