def photo_img(self): im = ImageManager() if self.photo: return Markup('<a href="' + url_for('ProductPubView.show', pk=str(self.id)) + '" class="thumbnail"><img src="' + im.get_url(self.photo) + '" alt="Photo" class="img-rounded img-responsive"></a>') else: return Markup('<a href="' + url_for('ProductPubView.show', pk=str(self.id)) + '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>')
def photo_img(self): im = ImageManager() if self.photo: return Markup( '<a href="' + url_for("ProductPubView.show", pk=str(self.id)) + '" class="thumbnail"><img src="' + im.get_url(self.photo) + '" alt="Photo" class="img-rounded img-responsive"></a>') else: return Markup( '<a href="' + +url_for("ProductPubView.show", pk=str(self.id)) + '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive">' '</a>')
def vendor_img(self): im = ImageManager() if self.vendor_site_image: return Markup( '<a href="' + url_for('VendorSitesModelView.show', pk=str(self.id)) + '" class="thumbnail"><img src="' + im.get_url(self.vendor_site_image) + '" alt="Photo" class="img-rounded img-responsive"></a>') else: return Markup( '<a href="' + url_for('VendorSitesModelView.show', pk=str(self.id)) + '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>' )
def _image(self, name): im = ImageManager() imagen = getattr(self, name) if imagen: # url = url_for('ProductPubView.show', pk=str(self.id)) # return Markup('<a href="' + url + '" class="thumbnail"><img src="' + # im.get_url(imagen) + '" alt="Photo" class="img-rounded img-responsive"></a>') return Markup( '<center><img src="' + im.get_url(imagen) + '" alt="Photo" class="img-rounded img-responsive"></center>') else: # return Markup('<a href="' + url_for('ProductPubView.show', pk=str(self.id)) + # '" class="thumbnail"><img src="//:0" alt="Photo" class="img-responsive"></a>') #return Markup('<center><img src="//:0" alt="Photo" class="img-responsive"></center>') return ''
def show_images(self): thumbs = ImageManager() thumbs.relative_path = 'static/uploads/images/' SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) # print SITE_ROOT paths = os.path.join(current_app.root_path, current_app.static_folder, 'uploads/images') print current_app.static_folder # print paths files = [ thumbs.get_url(f) for f in os.listdir(config.IMG_UPLOAD_FOLDER) if os.path.isfile(os.path.join(config.IMG_UPLOAD_FOLDER, f)) ] myfiles = self.appbuilder.get_session.query(Media).all() print self.appbuilder.static_url_path file_display = [] for f in myfiles: fl = f.name # fpath = os.path.join(config.IMG_UPLOAD_FOLDER, fl) fpath = self.appbuilder.static_url_path + '/uploads/images/' + fl files, file_extension = os.path.splitext(fpath) th = files + '_thumb' + file_extension # size = os.path.getsize(os.path.join('/home/afidegnum/PycharmProjects/myfab/app/', f)) # furl = os.path.getsize(os.path.join('/home/afidegnum/PycharmProjects/myfab/app/', f)) json_display = { "deleteType": "DELETE", 'name': fl, 'url': self.appbuilder.static_url_path + '/uploads/images/' + fl, 'thumbnailUrl': th, 'deleteUrl': 'delete/' + fl, 'size': 888 } # file_saved = uploadfile(name=f, size=size) # file_saved.url = config.NEUTRAL_PATH + f file_display.append(json_display) return simplejson.dumps({"files": file_display})
def dr_img(self): im = ImageManager() if self.plot_png: return Markup('<img src="' + im.get_url(self.plot_png) +\ '" alt="Dose response plot" >')