0
A
回答
1
我使用的解決方案是Flutter模塊,它讓我創建自定義內容類型。
1
它目前不可能(幾個月沒有運氣一直照顧它)。
您是否試圖將該圖像顯示爲縮略圖(同時保持作者的方便)?
最好的方法是自動檢測帖子中的第一張圖片。用戶無需處理自定義字段,也不網址:
// Get URL of first image in a post
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
// no image found display default image instead
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}
// With TimThumb
<img src="/thumb.php?src=<?php echo catch_that_image() ?>&w=200&zc=1&q=200" alt="<?php the_title(); ?>"/>
在這裏找到:http://snipplr.com/view/23968/wordpress--get-first-image-of-post-without-custom-fields/
如果這不是你要找的人,請提供更多的細節,我們將盡力找到解決辦法。
:)
0
這不是一個理想的解決方案,但我目前只使用一個被稱爲自定義字段「縮略圖」,並把上傳圖像的位置在那裏。然後,當我在某處顯示帖子詳細信息時,我使用自定義字段中的值作爲<img src="">
值。
要首先上傳圖片,我只需在編輯器中使用普通圖片上傳工具,並在我寫帖子時將上傳的名稱複製到自定義字段中。
不是很優雅,但它的工作原理。
最後我用了Flutter模塊來創建一個圖像字段。適合我! – Probocop 2010-05-10 08:33:44