admin管理员组文章数量:1323157
I am writing a WordPress plugin that will display a devotional image. One of the options I would like to include is image width. I am trying to wrap the image and some text in a div so I can style it and let the user chose some different styling options. However, just trying to set the div width using the variable is not working. It says there is a syntax error.
Any help would be appreciated! Thanks, Nick.
$imageWidth = get_option('devotional_imageWidth','100%');
$content = "<h2>Devotionally Images</h2>";
<div style="width:$imageWidth;">
print '<img src="' .$show_file. '" alt="Image Title Here">';
$content .= "devotional by Devotional.ly";
</div>
return $content;
}
add_shortcode('devotionally','devotionally_function');
I am writing a WordPress plugin that will display a devotional image. One of the options I would like to include is image width. I am trying to wrap the image and some text in a div so I can style it and let the user chose some different styling options. However, just trying to set the div width using the variable is not working. It says there is a syntax error.
Any help would be appreciated! Thanks, Nick.
$imageWidth = get_option('devotional_imageWidth','100%');
$content = "<h2>Devotionally Images</h2>";
<div style="width:$imageWidth;">
print '<img src="' .$show_file. '" alt="Image Title Here">';
$content .= "devotional by Devotional.ly";
</div>
return $content;
}
add_shortcode('devotionally','devotionally_function');
Share
Improve this question
edited Sep 2, 2020 at 7:41
Hector
6821 gold badge7 silver badges18 bronze badges
asked Sep 1, 2020 at 19:20
Nick LNick L
31 bronze badge
1 Answer
Reset to default 0There are invalid PHP codes in your sample. Try to use valid PHP code like below.
$imageWidth = get_option('devotional_imageWidth','100%');
$content = "<h2>Devotionally Images</h2>";
$content .= '<div style="width:' . $imageWidth. ';">';
$content .= '<img src="' .$show_file. '" alt="Image Title Here">';
$content .= "devotional by Devotional.ly";
$content .= '</div>';
return $content;
本文标签: phpTrying to use a variable to set image width
版权声明:本文标题:php - Trying to use a variable to set image width 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742143072a2422668.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论