MODx Gallery 无法正确显示图像
我最近使用 MODx Revolution 建立了一个网站。我正在尝试使用同名插件制作一个画廊。我希望您可以单击一个链接,该链接显示上传时的原始图像。以下是我的画廊页面的代码:
<div class="ContentHead">[[*longtitle]]</div>
<p>This page contains galleries of various images I have taken or made. Each has a description, so feel free to browse. Clicking thumbnails will reload the page, and may take some time to load a larger version of the image - but it will get there!</p>
<p>[[!Gallery? &toPlaceholder=`gallery`]] [[!GalleryItem? &imageWidth=`900` &imageHeight=`900`]] [[!GalleryAlbums? &prominentOnly=`0` &limit=`0` &rowTpl=`galAlbumRowTplCustom` &toPlaceholder=`galleries`]]</p>
<div align="center">| [[+galleries]]</div>
<hr />
<p><a name="largeImage"></a></p>
<p> </p>
<p>[[!+galitem.image:notempty=`</p><div class="image"><img class="[[+galitem.imgCls]]" src="[[+galitem.image]]" alt="[[+galitem.name]]" /><br/>[[+galitem.description]]<br />Albums: [[+galitem.albums]] <br />Tags: [[+galitem.tags]]<br/><a href="[[!+galitem.image]]">View original image</a><hr /></div> <p>`]]
[[!+gallery:notempty=`</p><div ><h1 style="font-size: 20px; font-weight: bold; font-family: Calibri;">[[+gallery.name]]</h1><h2 style="font-size: 18px; font-weight: normal; font-family: Calibri;">[[+gallery.description]]</h2><p> </p><h2 style="font-size: 18px; font-weight: normal; font-family: Calibri;">[[+gallery]]</h2> </div>`]]
<div style="height:600px"><!--This ensures that when a thumb is clicked, the gallery isn't pushed below the footer.--></div>
导致问题的代码是:
<a href="[[!+galitem.image]]">View original image</a>
生成以下(示例)url:
http://www.reflectric.com/assets/components/gallery/connector.php?action=web/phpthumb&w=900&h=900&zc=0&far=&q=90&src=http%3A%2F%2Fwww.reflectric.com%2Fassets%2Fcomponents%2Fgallery%2Ffiles%2F3%2F28.bmp
如果您在 Internet Explorer 上遵循它(继续,尝试一下!)(在 6 和 9 上测试),它显示图像很好。然而,在我测试过的所有其他浏览器上,它给出的结果与在记事本++或其他文本编辑器中加载图像所得到的结果相同。
在图像上执行“右键单击另存为”会导致保存 php 重定向,而不是图像,并且“右键单击查看图像”给出与上面的链接相同的效果。
因此,我要问的是 a) 有没有办法解决这个问题, 或者 b) 有没有办法直接链接到图像,而不是通过 php 页面?
感谢您提供的任何帮助,
西蒙
I have recently set up a website using MODx Revolution. I am attempting to make a gallery, using the plugin of the same name. I would like it so that you can click a link, which displays the original image, as it was uploaded. Here is the code for my gallery page:
<div class="ContentHead">[[*longtitle]]</div>
<p>This page contains galleries of various images I have taken or made. Each has a description, so feel free to browse. Clicking thumbnails will reload the page, and may take some time to load a larger version of the image - but it will get there!</p>
<p>[[!Gallery? &toPlaceholder=`gallery`]] [[!GalleryItem? &imageWidth=`900` &imageHeight=`900`]] [[!GalleryAlbums? &prominentOnly=`0` &limit=`0` &rowTpl=`galAlbumRowTplCustom` &toPlaceholder=`galleries`]]</p>
<div align="center">| [[+galleries]]</div>
<hr />
<p><a name="largeImage"></a></p>
<p> </p>
<p>[[!+galitem.image:notempty=`</p><div class="image"><img class="[[+galitem.imgCls]]" src="[[+galitem.image]]" alt="[[+galitem.name]]" /><br/>[[+galitem.description]]<br />Albums: [[+galitem.albums]] <br />Tags: [[+galitem.tags]]<br/><a href="[[!+galitem.image]]">View original image</a><hr /></div> <p>`]]
[[!+gallery:notempty=`</p><div ><h1 style="font-size: 20px; font-weight: bold; font-family: Calibri;">[[+gallery.name]]</h1><h2 style="font-size: 18px; font-weight: normal; font-family: Calibri;">[[+gallery.description]]</h2><p> </p><h2 style="font-size: 18px; font-weight: normal; font-family: Calibri;">[[+gallery]]</h2> </div>`]]
<div style="height:600px"><!--This ensures that when a thumb is clicked, the gallery isn't pushed below the footer.--></div>
The code that is causing the problems is:
<a href="[[!+galitem.image]]">View original image</a>
which generates the following (example) url:
http://www.reflectric.com/assets/components/gallery/connector.php?action=web/phpthumb&w=900&h=900&zc=0&far=&q=90&src=http%3A%2F%2Fwww.reflectric.com%2Fassets%2Fcomponents%2Fgallery%2Ffiles%2F3%2F28.bmp
If you follow it (go ahead, try it!) on Internet Explorer (tested on 6 and 9), it shows the image just fine. On every other browser i've tested, however, it gives the same as you would get from loading the image in notepad++ or another text editor.
doing "Right-click Save As" on the image causes the php redirect to be saved, rather than the image, and "Right-click view image" gives the same as the link above.
Therefore, I am asking either
a) is there a way to fix this,
or b) is there a way to link to the image directly, instead of going via the php page?
Thanks for any help you can give,
Simon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的 MIME 类型配置似乎不正确。 PHP 脚本connector.php 应该告诉浏览器当前提供的URL 是一个图像。
但是,如果您使用 Firebug(或 Chrome Dev / Safari Dev 等)并检查您的响应类型,它会给您:
内容类型“text/html”不是您想要提供的内容,但这就是服务器/php 的内容- 脚本给出。
检查您的 Apache(如果您喜欢的话)配置,或者,如果您使用的是网络托管,请检查您的 .htaccess 文件。
其他网络服务器(nginx、lighttpd、cherokee...)也存在类似的配置。如果它不起作用,您可以调整连接器脚本(尚未检查其源)以强制使用 MIME 类型。在 在 php 脚本中显示图像中讨论过
(我意识到自从你发布了这个问题,但由于它没有标记为已解决,我希望这会对您或其他人有所帮助)
It seems like your MIME-type configuration is incorrect. The PHP-script connector.php should tell browser that the currently served URL is an image.
However, if you use Firebug (or Chrome Dev / Safari Dev etc) and check your response type, it will give you:
Content-type "text/html" is not what you want to serve, but that is what the server/php-script gives.
Check your Apache (if that's what you fancy) configuration OR, if you're using a web hosting, your .htaccess-file.
Similar configuration exists for other webservers (nginx, lighttpd, cherokee...) as well. If it didn't work you can tweak the connector-script (haven't checked its source) to force a MIME-type. Discussed in Show image in php script
(I realize that is was over a month since you posted this question, but since it wasn't marked as solved I hope this will help you or someone else)
在模板块中尝试 [[+image_absolute]] 。
有点困惑为什么有人会把这个发布到 StackOverflow 而不是 MODX 论坛上 - 有更多的人在监视(我只是通过 Twitter 到达这里)。
Try [[+image_absolute]] in your template chunk.
Sort of stumped why one would post this on StackOverflow instead of on the MODX forums though - there's more people monitoring that (I only got here via Twitter).
这是 Gallery 1.2.0 的问题,已在 1.2.1 中解决。
感谢您的所有建议!
This was an issue with Gallery 1.2.0, which has been solved in 1.2.1.
Thanks for all your suggestions!