1

PHP文字列によって生成される高さと幅のhtml属性を指定する必要があるリンクされた画像があります。getimagesize の使用を検討しましたが、必要なもののようには見えません。私は現在ソーシャルエンジンを使用しています。

これは、画像リンクを呼び出す文字列です。

<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '')) ?>

次のようなhtmlを出力します<a href="#"><img src="#" class="null"/></a>

php を変更して、110px x 110px に指定された画像を作成する必要があります。<a href="#"><img src="#" class="null" width="110" height="110"/></a>

文字列を書く方法の例を誰か教えてもらえますか?

4

4 に答える 4

3

これを使用する必要があります:

<?php echo $this->htmlLink(
    $item->getHref(), 
    $this->itemPhoto(
        $item, 
        'null', 
        null, 
        array('width' => '110px', 'height' => '110px')), 
    array('class' => '')
) ?>

つまり、関数に 4 番目のパラメーター配列を追加しitemPhotoます。

Socialengine は Zend フレームワークの拡張です。などの関数の定義を調べて、それらをカスタマイズする必要がありitemPhotoます。htmlLinkたとえば、itemPhotoここにあります - \application\modules\Core\View\Helper\ItemPhoto.php

于 2012-05-23T02:11:22.027 に答える
2

最後のパラメーターはそのために使用されますね。

$this->htmlLink(
  $item->getHref(), 
  $this->itemPhoto($item, '', '', array('width' => 110, 'height' => 110)),
  array('class' => '')
);
于 2012-05-22T07:52:29.670 に答える
1

Method1: null クラスのスタイルを追加するだけ

<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '')) ?>

なので:

.null {
  height: 110px;
  width: 110px;
}

Method2: または、インライン スタイル属性を次のように渡すことができます。

<?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'null'), array('class' => '', 'style' => 'height: 110px; width: 110px')) ?>
于 2012-05-22T08:05:43.033 に答える
0

関数 htmlLink() の背後にあるものはわかりませんが、渡す要素の名前が原因で、書くことができると思います。

echo '<a href="'.$item->getHref().'"><img src="'.$this->itemPhoto($item, 'null').'" class="null" width="110" height="110"/></a>';

しかし、エーテルはその機能を投稿するか、試行錯誤してください!

于 2012-05-22T07:57:58.580 に答える