1

Drupal 7 でモジュールを作成しています。UNIX タイムスタンプを日付にフォーマットしたい場合は、次のように format_date 関数を使用できます。

$date = format_date($node->created, 'custom', 'j F Y');

画像をフォーマットするために参照できる関数もありますか? データベースクエリが返されるとします

picture-4-136576449.png

テーブルから、次のように変換したい:

<img src="/images/picture-4-136576449.png />

それを行う機能はありますか?ありがとう。

4

1 に答える 1

0

を URLに変換しようとしているURI場合は、間違っています。

$uri = 'public://images/my-photo.png';
$url = file_create_url($uri);
// $url should be publicly accessible URL now. 

Drupal ルートからの相対的なイメージへのパスがわかっている場合は、次を使用します。

$url = url('path/to/image.png', array('alias' => FALSE));

を使用して画像のテーマを設定できますtheme('image', $variables)

元:

<?php 
print theme('image', array('path' => 'path/to/image.png', 
                           'title' => t('Some title'), //optional
                           'alt' => t('Some alt text'), //optional
                      ));

theme_image() function doc pageで他の変数を確認できます。

于 2013-02-07T19:33:15.747 に答える