【问题标题】:MODx Gallery not displaying images correctlyMODx Gallery 无法正确显示图像
【发布时间】:2011-06-05 20:57:35
【问题描述】:

我最近使用 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 上测试)上关注它(继续,试试吧!),它会很好地显示图像。然而,在我测试过的所有其他浏览器上,它提供的结果与在 notepad++ 或其他文本编辑器中加载图像时获得的结果相同。

在图片上“右键另存为”会导致保存php重定向,而不是图片,“右键查看图片”给出的结果与上面的链接相同。

因此,我要问的是 a)有没有办法解决这个问题, 或者 b) 有没有办法直接链接到图像,而不是通过 php 页面?

感谢您提供的任何帮助,

西蒙

【问题讨论】:

    标签: php html gallery modx-revolution


    【解决方案1】:

    您的 MIME 类型配置似乎不正确。 PHP 脚本 connector.php 应该告诉浏览器当前提供的 URL 是一个图像。

    但是,如果您使用 Firebug(或 Chrome Dev / Safari Dev 等)并检查您的响应类型,它将为您提供:

    HTTP/1.1 200 OK
    Date: Mon, 18 Jul 2011 09:11:37 GMT
    Server: Apache
    X-Powered-By: PHP/5.2.17
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Keep-Alive: timeout=10, max=29
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html      <===================== INCORRECT!
    

    Content-type "text/html" 不是你想提供的,但那是 server/php-script 提供的。

    检查您的 Apache(如果您喜欢的话)配置,或者,如果您使用的是网络托管,请检查您的 .htaccess 文件。

    AddType image/jpg .jpg
    

    其他网络服务器(nginx、lighttpd、cherokee...)也存在类似的配置。如果它不起作用,您可以调整连接器脚本(尚未检查其来源)以强制使用 MIME 类型。讨论于Show image in php script

    (我知道距您发布此问题已有一个多月了,但由于它没有标记为已解决,我希望这会对您或其他人有所帮助)

    【讨论】:

    • splittingreds Gallery github-repo 上报告了一个类似的问题。然而,图像随后在不使用 ... 的情况下被提供。几天后,Bug 被关闭了。见:github.com/splittingred/Gallery/issues/104
    • 这条评论是正确答案——基本上是Gallery版本的问题,已经在下次更新中解决了
    【解决方案2】:

    在您的模板块中尝试 [[+image_absolute]]。

    有点难过为什么有人会在 StackOverflow 上而不是在 MODX 论坛上发布这个 - 有更多的人在监视它(我只是通过 Twitter 到这里的)。

    【讨论】:

    • Stack Overflow 确实有一些 MODx 问题 - 我之前在 MODx 论坛上问过但没有得到答案,而我总是在这里得到一个……而且我在这里获得了声誉:-P跨度>
    • [[+image_absolute]] 不起作用,甚至无法解析为有效链接(它只是转到我的主页)。澄清一下,我没有安装 phpthumb - 只是 Gallery 附带的。
    【解决方案3】:

    这是 Gallery 1.2.0 的问题,已在 1.2.1 中解决。

    感谢您的所有建议!

    【讨论】:

    • wolff 回答了这个问题,你就赢了 :)
    猜你喜欢
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 2020-08-27
    • 2021-09-26
    • 2018-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多