better image attachment detection for inlining

This commit is contained in:
Andrew Dolgov 2010-02-05 13:13:51 +03:00
parent 3393238de2
commit 44cfa02554
1 changed files with 14 additions and 8 deletions

View File

@ -4920,19 +4920,22 @@
print "<div class=\"postEnclosures\">"; print "<div class=\"postEnclosures\">";
if (!get_pref($link, "STRIP_IMAGES")) { if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) { if ($always_display_enclosures ||
!preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) { foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"])) {
print "<p><img if (preg_match("/image/", $entry["type"]) ||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img
alt=\"".htmlspecialchars($entry["filename"])."\" alt=\"".htmlspecialchars($entry["filename"])."\"
src=\"" .htmlspecialchars($entry["url"]) . "\"></p>"; src=\"" .htmlspecialchars($entry["url"]) . "\"/></p>";
} }
} }
} }
} }
print "<div class=\"postEnclosures\">";
if (db_num_rows($result) == 1) { if (db_num_rows($result) == 1) {
print __("Attachment:") . " "; print __("Attachment:") . " ";
} else { } else {
@ -5501,9 +5504,12 @@
$always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures"); $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures");
if (!get_pref($link, "STRIP_IMAGES")) { if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures || !preg_match("/img/i", $article_content)) { if ($always_display_enclosures ||
!preg_match("/img/i", $article_content)) {
foreach ($entries as $entry) { foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"])) { if (preg_match("/image/", $entry["type"]) ||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img print "<p><img
alt=\"".htmlspecialchars($entry["filename"])."\" alt=\"".htmlspecialchars($entry["filename"])."\"
src=\"" .htmlspecialchars($entry["url"]) . "\"></p>"; src=\"" .htmlspecialchars($entry["url"]) . "\"></p>";