本文整理汇总了PHP中RevSliderFunctionsWP::getUrlAttachmentImage方法的典型用法代码示例。如果您正苦于以下问题:PHP RevSliderFunctionsWP::getUrlAttachmentImage方法的具体用法?PHP RevSliderFunctionsWP::getUrlAttachmentImage怎么用?PHP RevSliderFunctionsWP::getUrlAttachmentImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RevSliderFunctionsWP
的用法示例。
在下文中一共展示了RevSliderFunctionsWP::getUrlAttachmentImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_image_attributes
public function get_image_attributes($slider_type)
{
$params = $this->params;
$bgType = RevSliderBase::getVar($params, "background_type", "transparent");
$bgColor = RevSliderBase::getVar($params, "slide_bg_color", "transparent");
$bgFit = RevSliderBase::getVar($params, "bg_fit", "cover");
$bgFitX = intval(RevSliderBase::getVar($params, "bg_fit_x", "100"));
$bgFitY = intval(RevSliderBase::getVar($params, "bg_fit_y", "100"));
$bgPosition = RevSliderBase::getVar($params, "bg_position", "center top");
$bgPositionX = intval(RevSliderBase::getVar($params, "bg_position_x", "0"));
$bgPositionY = intval(RevSliderBase::getVar($params, "bg_position_y", "0"));
$bgRepeat = RevSliderBase::getVar($params, "bg_repeat", "no-repeat");
$bgStyle = ' ';
if ($bgFit == 'percentage') {
$bgStyle .= "background-size: " . $bgFitX . '% ' . $bgFitY . '%;';
} else {
$bgStyle .= "background-size: " . $bgFit . ";";
}
if ($bgPosition == 'percentage') {
$bgStyle .= "background-position: " . $bgPositionX . '% ' . $bgPositionY . '%;';
} else {
$bgStyle .= "background-position: " . $bgPosition . ";";
}
$bgStyle .= "background-repeat: " . $bgRepeat . ";";
$thumb = '';
switch ($slider_type) {
case 'gallery':
$imageID = RevSliderBase::getVar($params, "image_id");
if (empty($imageID)) {
$thumb = RevSliderBase::getVar($params, "image");
$imgID = RevSliderBase::get_image_id_by_url($thumb);
if ($imgID !== false) {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imgID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
} else {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imageID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
break;
case 'posts':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/post.png';
$bgStyle = 'background-size: cover;';
break;
case 'facebook':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/fb.png';
$bgStyle = 'background-size: cover;';
break;
case 'twitter':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/tw.png';
$bgStyle = 'background-size: cover;';
break;
case 'instagram':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/ig.png';
$bgStyle = 'background-size: cover;';
break;
case 'flickr':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/fr.png';
$bgStyle = 'background-size: cover;';
break;
case 'youtube':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/yt.png';
$bgStyle = 'background-size: cover;';
break;
case 'vimeo':
$thumb = RS_PLUGIN_URL . 'public/assets/assets/sources/vm.png';
$bgStyle = 'background-size: cover;';
break;
}
if ($thumb == '') {
$thumb = RevSliderBase::getVar($params, "image");
}
$bg_fullstyle = '';
$bg_extraClass = '';
$data_urlImageForView = '';
//if($bgType=="image" || $bgType=="streamvimeo" || $bgType=="streamyoutube" || $bgType=="streaminstagram" || $bgType=="html5") {
$data_urlImageForView = $thumb;
$bg_fullstyle = $bgStyle;
//}
if ($bgType == "solid") {
$bg_fullstyle = 'background-color:' . $bgColor . ';';
}
if ($bgType == "trans" || $bgType == "transparent") {
$bg_extraClass = 'mini-transparent';
}
return array('url' => $data_urlImageForView, 'class' => $bg_extraClass, 'style' => $bg_fullstyle);
}
示例2: write_template_markup
/**
* output markup for template
* @since: 5.0
*/
public function write_template_markup($template, $slider_id = false)
{
$params = $template['params'];
$settings = $template['settings'];
$slide_id = $template['id'];
if ($slider_id !== false) {
$title = '';
}
//remove Title if Slider
$width = RevSliderBase::getVar($settings, "width", 1240);
$height = RevSliderBase::getVar($settings, "height", 868);
$bgType = RevSliderBase::getVar($params, "background_type", "transparent");
$bgColor = RevSliderBase::getVar($params, "slide_bg_color", "transparent");
$bgFit = RevSliderBase::getVar($params, "bg_fit", "cover");
$bgFitX = intval(RevSliderBase::getVar($params, "bg_fit_x", "100"));
$bgFitY = intval(RevSliderBase::getVar($params, "bg_fit_y", "100"));
$bgPosition = RevSliderBase::getVar($params, "bg_position", "center center");
$bgPositionX = intval(RevSliderBase::getVar($params, "bg_position_x", "0"));
$bgPositionY = intval(RevSliderBase::getVar($params, "bg_position_y", "0"));
$bgRepeat = RevSliderBase::getVar($params, "bg_repeat", "no-repeat");
$bgStyle = ' ';
if ($bgFit == 'percentage') {
if (intval($bgFitY) == 0 || intval($bgFitX) == 0) {
$bgStyle .= "background-size: cover;";
} else {
$bgStyle .= "background-size: " . $bgFitX . '% ' . $bgFitY . '%;';
}
} else {
$bgStyle .= "background-size: " . $bgFit . ";";
}
if ($bgPosition == 'percentage') {
$bgStyle .= "background-position: " . $bgPositionX . '% ' . $bgPositionY . '%;';
} else {
$bgStyle .= "background-position: " . $bgPosition . ";";
}
$bgStyle .= "background-repeat: " . $bgRepeat . ";";
if (isset($template['img'])) {
$thumb = $this->_check_file_path($template['img'], true);
} else {
$imageID = RevSliderBase::getVar($params, "image_id");
if (empty($imageID)) {
$thumb = RevSliderBase::getVar($params, "image");
$imgID = RevSliderBase::get_image_id_by_url($thumb);
if ($imgID !== false) {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imgID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
} else {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imageID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
if ($thumb == '') {
$thumb = RevSliderBase::getVar($params, "image");
}
}
$bg_fullstyle = '';
$bg_extraClass = '';
$data_urlImageForView = '';
if (isset($template['img'])) {
$data_urlImageForView = 'data-src="' . $thumb . '"';
} else {
if ($bgType == 'image' || $bgType == 'vimeo' || $bgType == 'youtube' || $bgType == 'html5') {
$data_urlImageForView = 'data-src="' . $thumb . '"';
$bg_fullstyle = ' style="' . $bgStyle . '" ';
}
if ($bgType == "solid") {
$bg_fullstyle = ' style="background-color:' . $bgColor . ';" ';
}
if ($bgType == "trans" || $bgType == "transparent") {
$bg_extraClass = 'mini-transparent';
}
}
?>
<div class="template_slide_single_element" style="display:inline-block">
<div <?php
echo $data_urlImageForView;
?>
class="<?php
echo $slider_id !== false ? 'template_slider_item' : 'template_item';
?>
<?php
echo $bg_extraClass;
?>
" <?php
echo $bg_fullstyle;
?>
data-gridwidth="<?php
echo $width;
?>
"
data-gridheight="<?php
echo $height;
?>
"
<?php
if ($slider_id !== false) {
?>
data-sliderid="<?php
//.........这里部分代码省略.........
示例3: write_template_markup
/**
* output markup for template
* @since: 5.0
*/
public function write_template_markup($template, $slider_id = false)
{
$params = $template['params'];
$settings = $template['settings'];
$slide_id = $template['id'];
$title = str_replace("'", "", RevSliderBase::getVar($params, 'title', 'Slide'));
if ($slider_id !== false) {
$title = '';
}
//remove Title if Slider
$width = RevSliderBase::getVar($settings, "width", 1240);
$height = RevSliderBase::getVar($settings, "height", 868);
$bgType = RevSliderBase::getVar($params, "background_type", "transparent");
$bgColor = RevSliderBase::getVar($params, "slide_bg_color", "transparent");
$bgFit = RevSliderBase::getVar($params, "bg_fit", "cover");
$bgFitX = intval(RevSliderBase::getVar($params, "bg_fit_x", "100"));
$bgFitY = intval(RevSliderBase::getVar($params, "bg_fit_y", "100"));
$bgPosition = RevSliderBase::getVar($params, "bg_position", "center center");
$bgPositionX = intval(RevSliderBase::getVar($params, "bg_position_x", "0"));
$bgPositionY = intval(RevSliderBase::getVar($params, "bg_position_y", "0"));
$bgRepeat = RevSliderBase::getVar($params, "bg_repeat", "no-repeat");
$bgStyle = ' ';
if ($bgFit == 'percentage') {
if (intval($bgFitY) == 0 || intval($bgFitX) == 0) {
$bgStyle .= "background-size: cover;";
} else {
$bgStyle .= "background-size: " . $bgFitX . '% ' . $bgFitY . '%;';
}
} else {
$bgStyle .= "background-size: " . $bgFit . ";";
}
if ($bgPosition == 'percentage') {
$bgStyle .= "background-position: " . $bgPositionX . '% ' . $bgPositionY . '%;';
} else {
$bgStyle .= "background-position: " . $bgPosition . ";";
}
$bgStyle .= "background-repeat: " . $bgRepeat . ";";
if (isset($template['img'])) {
$thumb = $this->_check_file_path($template['img'], true);
} else {
$imageID = RevSliderBase::getVar($params, "image_id");
if (empty($imageID)) {
$thumb = RevSliderBase::getVar($params, "image");
$imgID = RevSliderBase::get_image_id_by_url($thumb);
if ($imgID !== false) {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imgID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
} else {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imageID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
if ($thumb == '') {
$thumb = RevSliderBase::getVar($params, "image");
}
}
$bg_fullstyle = '';
$bg_extraClass = '';
$data_urlImageForView = '';
if (isset($template['img'])) {
$data_urlImageForView = 'data-src="' . $thumb . '"';
} else {
if ($bgType == 'image' || $bgType == 'vimeo' || $bgType == 'youtube' || $bgType == 'html5') {
$data_urlImageForView = 'data-src="' . $thumb . '"';
$bg_fullstyle = ' style="' . $bgStyle . '" ';
}
if ($bgType == "solid") {
$bg_fullstyle = ' style="background-color:' . $bgColor . ';" ';
}
if ($bgType == "trans" || $bgType == "transparent") {
$bg_extraClass = 'mini-transparent';
}
}
?>
<div class="template_slide_single_element" style="display:inline-block">
<div <?php
echo $data_urlImageForView;
?>
class="<?php
echo $slider_id !== false ? 'template_slider_item' : 'template_item';
?>
<?php
echo $bg_extraClass;
?>
" <?php
echo $bg_fullstyle;
?>
data-gridwidth="<?php
echo $width;
?>
"
data-gridheight="<?php
echo $height;
?>
"
<?php
if ($slider_id !== false) {
?>
//.........这里部分代码省略.........
示例4: write_template_markup
/**
* output markup for template
* @since: 5.0
*/
public function write_template_markup($template, $slider_id = false)
{
$params = $template['params'];
$settings = $template['settings'];
$slide_id = $template['id'];
$title = str_replace("'", "", RevSliderBase::getVar($params, 'title', 'Slide'));
if ($slider_id !== false) {
$title = '';
}
//remove Title if Slider
$width = RevSliderBase::getVar($settings, "width", 1240);
$height = RevSliderBase::getVar($settings, "height", 868);
$bgType = RevSliderBase::getVar($params, "background_type", "transparent");
$bgColor = RevSliderBase::getVar($params, "slide_bg_color", "transparent");
$bgFit = RevSliderBase::getVar($params, "bg_fit", "cover");
$bgFitX = intval(RevSliderBase::getVar($params, "bg_fit_x", "100"));
$bgFitY = intval(RevSliderBase::getVar($params, "bg_fit_y", "100"));
$bgPosition = RevSliderBase::getVar($params, "bg_position", "center center");
$bgPositionX = intval(RevSliderBase::getVar($params, "bg_position_x", "0"));
$bgPositionY = intval(RevSliderBase::getVar($params, "bg_position_y", "0"));
$bgRepeat = RevSliderBase::getVar($params, "bg_repeat", "no-repeat");
$bgStyle = ' ';
if ($bgFit == 'percentage') {
if (intval($bgFitY) == 0 || intval($bgFitX) == 0) {
$bgStyle .= "background-size: cover;";
} else {
$bgStyle .= "background-size: " . $bgFitX . '% ' . $bgFitY . '%;';
}
} else {
$bgStyle .= "background-size: " . $bgFit . ";";
}
if ($bgPosition == 'percentage') {
$bgStyle .= "background-position: " . $bgPositionX . '% ' . $bgPositionY . '%;';
} else {
$bgStyle .= "background-position: " . $bgPosition . ";";
}
$bgStyle .= "background-repeat: " . $bgRepeat . ";";
if (isset($template['img'])) {
$thumb = $template['img'];
} else {
$imageID = RevSliderBase::getVar($params, "image_id");
if (empty($imageID)) {
$thumb = RevSliderBase::getVar($params, "image");
$imgID = RevSliderBase::get_image_id_by_url($thumb);
if ($imgID !== false) {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imgID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
} else {
$thumb = RevSliderFunctionsWP::getUrlAttachmentImage($imageID, RevSliderFunctionsWP::THUMB_MEDIUM);
}
if ($thumb == '') {
$thumb = RevSliderBase::getVar($params, "image");
}
}
$bg_fullstyle = '';
$bg_extraClass = '';
$data_urlImageForView = '';
if ($bgType == 'image' || $bgType == 'vimeo' || $bgType == 'youtube' || $bgType == 'html5') {
$data_urlImageForView = 'data-src="' . $thumb . '"';
$bg_fullstyle = ' style="' . $bgStyle . '" ';
}
if ($bgType == "solid") {
$bg_fullstyle = ' style="background-color:' . $bgColor . ';" ';
}
if ($bgType == "trans" || $bgType == "transparent") {
$bg_extraClass = 'mini-transparent';
}
?>
<div <?php
echo $data_urlImageForView;
?>
class="<?php
echo $slider_id !== false ? 'template_slider_item' : 'template_item';
?>
<?php
echo $bg_extraClass;
?>
" <?php
echo $bg_fullstyle;
?>
data-gridwidth="<?php
echo $width;
?>
"
data-gridheight="<?php
echo $height;
?>
"
<?php
if ($slider_id !== false) {
?>
data-sliderid="<?php
echo $slider_id;
?>
"
<?php
//.........这里部分代码省略.........