Cloudinary with Django-在页面呈现后,使用javascript动态增加/减少照片宽度和高度
我有一个Django应用程序,我使用Cloudinary来交付图像 图像以固定宽度和高度的模板显示,如下所示:Cloudinary with Django-在页面呈现后,使用javascript动态增加/减少照片宽度和高度,javascript,django,cloudinary,Javascript,Django,Cloudinary,我有一个Django应用程序,我使用Cloudinary来交付图像 图像以固定宽度和高度的模板显示,如下所示: <a href="/photo/{{ photo.id }}/"> {% cloudinary photo.filename width=100 height=100 crop="fill" %} </a> 我设想使用上面的脚本循环渲染照片元素,用新照片替换现有照片 但是很难找到解决方法。如果您想获得新的URL,可以设置宽度/高度: myWidth =
<a href="/photo/{{ photo.id }}/">
{% cloudinary photo.filename width=100 height=100 crop="fill" %}
</a>
我设想使用上面的脚本循环渲染照片元素,用新照片替换现有照片
但是很难找到解决方法。如果您想获得新的URL,可以设置宽度/高度:
myWidth = 300
myHight = 300
cloudinary.CloudinaryImage("sample").build_url(
width = myWidth, height = myHight, crop = 'fill')
结果将是:
好的,虽然这是Python服务器端,但它让我走上了不同的道路,这帮助我找到了Cloudinary jquery
$.Cloudinary.url
,我可以使用它创建新的图像源,并使用新的高度/宽度替换现有的源。我将Cloudinary公共文件名保存为图像id。然后将新的src url构建为:var src_url=$.Cloudinary.url(this.id+'.jpg',{width:newZoom,height:newZoom,crop:'fill'})代码>
myWidth = 300
myHight = 300
cloudinary.CloudinaryImage("sample").build_url(
width = myWidth, height = myHight, crop = 'fill')