{"id":5778,"date":"2025-03-27T10:02:00","date_gmt":"2025-03-27T02:02:00","guid":{"rendered":"https:\/\/www.baishitou.cn\/?p=5778"},"modified":"2025-04-03T15:52:06","modified_gmt":"2025-04-03T07:52:06","slug":"dedebiz%e6%96%87%e7%ab%a0%e5%86%85%e5%9b%be%e7%89%87alt%e3%80%81%e5%9b%be%e7%89%87%e6%a0%87%e9%a2%98%e8%87%aa%e5%8a%a8%e6%b7%bb%e5%8a%a0%e4%b8%ba%e6%a0%87%e9%a2%98%e3%80%81%e5%8e%bb%e6%8e%89%e5%9b%be","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/5778.html","title":{"rendered":"DEDEBIZ\u6587\u7ae0\u5185\u56fe\u7247ALT\u3001\u56fe\u7247\u6807\u9898\u81ea\u52a8\u6dfb\u52a0\u4e3a\u6807\u9898\u3001\u53bb\u6389\u56fe\u7247\u6837\u5f0f"},"content":{"rendered":"

DEDEBIZ\u7f51\u7ad9\u7ba1\u7406\u7cfb\u7edf\u73b0\u5728\u53ef\u4ee5\u81ea\u52a8\u7ed9\u6587\u7ae0\u5185\u7684\u56fe\u7247\u52a0\u4e0aALT\u3001\u6807\u9898\u5e76\u53bb\u6389\u56fe\u7247\u7684\u6837\u5f0f\uff0c\u8fd9\u6837\u5373\u65b9\u4fbf\u4e86SEO\uff0c\u53c8\u53ef\u4ee5\u56fe\u7247\u9632\u6b62\u5728\u67d0\u4e2a\u5206\u8fa8\u7387\u4e0b\u53d8\u5f62\uff0c\u4f46\u9ed8\u8ba4\u6a21\u677f\u91cc\u9762\u5e76\u6ca1\u6709\u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\uff0c\u5176\u5b9e\u8fd9\u4e00\u6548\u679c\u5728\u6269\u5c55\u91cc\u9762\u5df2\u7ecf\u6dfb\u52a0\u4e86\uff0c\u53ea\u9700\u8c03\u7528\u5373\u53ef\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u4f7f\u7528\u65b9\u6cd5\uff1a\u6253\u5f00\u5185\u5bb9\u9875\u6a21\u677f\u6587\u4ef6article_article.htm\uff0c\u628a<\/p>\n

{dede:field.body\/}\r\n<\/code><\/pre>\n

\u4fee\u6539\u4e3a<\/p>\n

{dede:field.body function='obtainalt(@me)'\/}\r\n<\/code><\/pre>\n

\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n

\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u8865\u5145\uff1a<\/strong>\u7531\u4e8e\u6211\u6d4b\u8bd5\u65f6\uff0c\u662f\u5728\u5df2\u53d1\u5e03\u7684\u6587\u7ae0\u91cc\u9762\u6dfb\u52a0\u7684\u56fe\u7247\uff0c\u6240\u4ee5\u663e\u793a\u6b63\u5e38\uff0c\u4f46\u65b0\u53d1\u5e03\u6587\u7ae0\u65f6\uff0c\u51fa\u73b0\u4e86\u4e0b\u9762\u7684\u9519\u8bef\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u4e34\u65f6\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n

\u628aextend.func.php\u91cc\u9762\u7684\u4ee3\u7801\u66ff\u6362\u4e00\u4e0b\u300257\u884c-70\u884c<\/p>\n

function obtainalt($newalt)\r\n{\r\n    global $dsql, $id, $aid;\r\n    $myid = isset($id) ? $id : $aid;\r\n    $row = $dsql->GetOne(\"SELECT title FROM `#@__archives` WHERE id='$myid'\");\r\n    \/\/\u56fe\u7247\u6ce8\u91ca\u81ea\u52a8\u4e3a\u6807\u9898\r\n    $newalt = str_ireplace(array('alt=\"\"', 'alt=\\'\\'', 'title=\"\"', 'title=\\'\\''), \"\", $newalt);\r\n    $newalt = str_ireplace(\"<img\", \"<img alt=\\\"\".$row['title'].\"\\\" title=\\\"\".$row['title'].\"\\\"\", $newalt);\r\n    \/\/\u53bb\u6389\u56fe\u7247\u5bbd\u5ea6\u548c\u9ad8\u5ea6\r\n    $newalt = preg_replace(\"\/style=\\\"width\\:(.*)\\\"\/\", \"\", $newalt);\r\n    \/\/\u53bb\u6389\u7ed3\u5c3e\r\n    $newalt = str_ireplace(\" \/\", \"\", $newalt);\r\n    return $newalt;\r\n}\r\n<\/code><\/pre>\n

\u66ff\u6362\u4e3a<\/p>\n

function obtainalt($newalt)\r\n{\r\n    global $dsql, $id, $aid;\r\n    $myid = isset($id) ? $id : $aid;\r\n    $row = $dsql->GetOne(\"SELECT title FROM `#@__archives` WHERE id='$myid'\");\r\n\r\n    \/\/ \u68c0\u67e5$row\u662f\u5426\u6709\u6548\r\n    $title = isset($row['title']) ? $row['title'] : '';\r\n\r\n    \/\/ \u56fe\u7247\u6ce8\u91ca\u81ea\u52a8\u4e3a\u6807\u9898\r\n    $newalt = str_ireplace(array('alt=\"\"', 'alt=\\'\\'', 'title=\"\"', 'title=\\'\\''), \"\", $newalt);\r\n    $newalt = str_ireplace(\"<img\", \"<img alt=\\\"\".$title.\"\\\" title=\\\"\".$title.\"\\\"\", $newalt);\r\n    \r\n    \/\/ \u53bb\u6389\u56fe\u7247\u5bbd\u5ea6\u548c\u9ad8\u5ea6\r\n    $newalt = preg_replace(\"\/style=\\\"width\\:(.*)\\\"\/\", \"\", $newalt);\r\n    \r\n    \/\/ \u53bb\u6389\u7ed3\u5c3e\r\n    $newalt = str_ireplace(\" \/\", \"\", $newalt);\r\n    \r\n    return $newalt;\r\n}\r\n\r\n<\/code><\/pre>\n

\u66ff\u6362\u540e\uff0c\u53d1\u5e03\u6587\u7ae0 \uff0c\u5c31\u6ca1\u9519\u8bef\u63d0\u793a\u4e86\u3002<\/p>\n

\u6700\u65b0\u7248\u672c\u7684\uff0c\u628a\u8fd9\u4e2aextend.func.php\u91cc\u9762\u7684\u5185\u5bb9\u6e05\u7a7a\u4e86\u3002\u4f60\u5982\u679c\u60f3\u9700\u8981\u8fd9\u4e2a\u529f\u80fd \uff0c\u53ef\u4ee5\u76f4\u63a5\u4e0a\u9762\u4fee\u6539\u7684\u4ee3\u7801\u653e\u8fdb\u53bb\u5c31\u884c\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

DEDEBIZ\u7f51\u7ad9\u7ba1\u7406\u7cfb\u7edf\u73b0\u5728\u53ef\u4ee5\u81ea\u52a8\u7ed9\u6587\u7ae0\u5185\u7684\u56fe\u7247\u52a0\u4e0aALT\u3001\u6807\u9898\u5e76\u53bb\u6389\u56fe\u7247\u7684\u6837\u5f0f\uff0c\u8fd9\u6837\u5373\u65b9\u4fbf\u4e86SEO\uff0c\u53c8\u53ef […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1778,1779,1780],"class_list":["post-5778","post","type-post","status-publish","format-standard","hentry","category-web","tag-alt","tag-1779","tag-1780"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/5778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=5778"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/5778\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=5778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=5778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=5778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}