0

文字列のすべての部分を可能な限り変更して別のフォルダーを含めようとして、何日もこれに苦労してきました。PhotoArtist テーマで Supersized jQuery スライダーを使用しています。ライブで見たい場合は、こちらのリンクをご覧ください: http://www.arjanbaagh.com/testsite/sliders-list/bridal-2013-collection/ .

私が達成しようとしている$outputのは、ファイル名の前に別のフォルダーを含めるように文字列を変更することです。プレビューに別のサムネイルを使用しようとしています。現在、スライダーはメイン プレビューから画像を取得し、動的に縮小します。ページにサムネイルを表示する PHP コードの行を次に示します。

$output .=" thumb : ". "'" . get_template_directory_uri() . "/framework/timthumb/timthumb.php?src=".thumb_link($element['img']) .  "&w=300&h=150'}";  

これにより、次の URL が出力されます。

http://www.arjanbaagh.com/testsite/wp-content/themes/photoartist-parent/framework/timthumb/timthumb.php?src=http://www.arjanbaagh.com/testsite/wp-content/uploads/ 2012/02/image02.jpg&w=300&h=150

私がしたいのは、$output文字列を変更して、image02.jpg の前に別のフォルダーが含まれるようにすることだけです。たとえば、URL を次のように変更します。

http://www.arjanbaagh.com/testsite/wp-content/themes/photoartist-parent/framework/timthumb/timthumb.php?src=http://www.arjanbaagh.com/testsite/wp-content/uploads/ 2012/02/ newfolder / image02.jpg&w=300&h=150

$output 文字列のディレクトリを変更しようとしましたが、文字列の先頭または末尾しか変更できません。

どんな助けでも大歓迎です!

4

1 に答える 1

1

これを既存の$output文字列の下に追加します。

/* Set the $output URL to a variable */    
$url = explode('/', $output);

/* Grab the last segment of the URL (image name and parameters) */
$lastSegment = end($url); // image02.jpg&w=300&h=150

/* Grab the first part of the entire original $output URL before the image string */
$partialUrl = explode($lastSegment, $output); // gets first part of url before image02.jpg&w=300&h=150

/* Grab the first returned value from $partialUrl, which is the string before the image name */
$firstHalf = $partialUrl[0]; // http://www.arjanbaagh.com/testsite/wp-content/themes/photoartist-parent/framework/timthumb/timthumb.php?src=http://www.arjanbaagh.com/testsite/wp-content/uploads/2012/02/

/* Add your directory */
$stringToAdd = 'newfolder/';

/* Final $output with your new directory in place */
$output = $firstHalf.$stringToAdd.$lastSegment
于 2013-03-20T18:30:13.677 に答える