本文整理汇总了PHP中RevSliderFunctionsWP::import_media方法的典型用法代码示例。如果您正苦于以下问题:PHP RevSliderFunctionsWP::import_media方法的具体用法?PHP RevSliderFunctionsWP::import_media怎么用?PHP RevSliderFunctionsWP::import_media使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RevSliderFunctionsWP
的用法示例。
在下文中一共展示了RevSliderFunctionsWP::import_media方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_file_in_zip
/**
* check if file is in zip
* @since: 5.0
*/
public static function check_file_in_zip($zip, $image, $filepath, $alias, &$alreadyImported, $add_path = false)
{
if (trim($image) !== '') {
if (strpos($image, 'http') !== false) {
} else {
$zimage = $zip->getStream('images/' . $image);
if (!$zimage) {
echo $image . __(' not found!<br>', REVSLIDER_TEXTDOMAIN);
} else {
if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $image])) {
$importImage = RevSliderFunctionsWP::import_media('zip://' . $filepath . "#" . 'images/' . $image, $alias . '/');
if ($importImage !== false) {
$alreadyImported['zip://' . $filepath . "#" . 'images/' . $image] = $importImage['path'];
$image = $importImage['path'];
}
} else {
$image = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $image];
}
}
if ($add_path) {
$upload_dir = wp_upload_dir();
$cont_url = $upload_dir['baseurl'];
$image = str_replace('uploads/uploads/', 'uploads/', $cont_url . '/' . $image);
}
}
}
return $image;
}
示例2: check_file_in_zip
/**
* check if file is in zip
* @since: 5.0
*/
public static function check_file_in_zip($d_path, $image, $alias, &$alreadyImported, $add_path = false)
{
global $wp_filesystem;
if (trim($image) !== '') {
if (strpos($image, 'http') !== false) {
} else {
$strip = false;
$zimage = $wp_filesystem->exists($d_path . 'images/' . $image);
if (!$zimage) {
$zimage = $wp_filesystem->exists(str_replace('//', '/', $d_path . 'images/' . $image));
$strip = true;
}
if (!$zimage) {
echo $image . __(' not found!<br>', 'revslider');
} else {
if (!isset($alreadyImported['images/' . $image])) {
if ($strip == true) {
//pclzip
$importImage = RevSliderFunctionsWP::import_media($d_path . str_replace('//', '/', 'images/' . $image), $alias . '/');
} else {
$importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $image, $alias . '/');
}
if ($importImage !== false) {
$alreadyImported['images/' . $image] = $importImage['path'];
$image = $importImage['path'];
}
} else {
$image = $alreadyImported['images/' . $image];
}
}
if ($add_path) {
$upload_dir = wp_upload_dir();
$cont_url = $upload_dir['baseurl'];
$image = str_replace('uploads/uploads/', 'uploads/', $cont_url . '/' . $image);
}
}
}
return $image;
}
示例3: importSliderFromPost
//.........这里部分代码省略.........
}
if ($did_change === true) {
$arrCreate = array();
$my_layers = json_encode($slide['layers']);
if (empty($my_layers)) {
$my_layers = stripslashes(json_encode($layers));
}
$arrCreate['layers'] = $my_layers;
$this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
}
}
}
}
//check if static slide exists and import
if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
$static_slide = $arrSlider['static_slides'];
foreach ($static_slide as $slide) {
$params = $slide["params"];
$layers = $slide["layers"];
$settings = @$slide["settings"];
//convert params images:
if (isset($params["image"])) {
//import if exists in zip folder
if (strpos($params["image"], 'http') !== false) {
} else {
if (trim($params["image"]) !== '') {
if ($importZip === true) {
//we have a zip, check if exists
$image = $zip->getStream('images/' . $params["image"]);
if (!$image) {
echo $params["image"] . __(' not found!<br>', REVSLIDER_TEXTDOMAIN);
} else {
if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) {
$importImage = RevSliderFunctionsWP::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/');
if ($importImage !== false) {
$alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path'];
$params["image"] = $importImage['path'];
}
} else {
$params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]];
}
}
}
}
$params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
}
}
//convert layers images:
foreach ($layers as $key => $layer) {
if (isset($layer["image_url"])) {
//import if exists in zip folder
if (trim($layer["image_url"]) !== '') {
if (strpos($layer["image_url"], 'http') !== false) {
} else {
if ($importZip === true) {
//we have a zip, check if exists
$image_url = $zip->getStream('images/' . $layer["image_url"]);
if (!$image_url) {
echo $layer["image_url"] . __(' not found!<br>');
} else {
if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) {
$importImage = RevSliderFunctionsWP::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/');
if ($importImage !== false) {
$alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path'];
$layer["image_url"] = $importImage['path'];
}
示例4: importSliderFromPost
//.........这里部分代码省略.........
if (empty($my_layers)) {
$my_layers = stripslashes(json_encode($layers));
}
$arrCreate['layers'] = $my_layers;
$this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
}
}
}
}
//check if static slide exists and import
if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
$static_slide = $arrSlider['static_slides'];
foreach ($static_slide as $slide) {
$params = $slide["params"];
$layers = $slide["layers"];
$settings = isset($slide["settings"]) ? $slide["settings"] : '';
//remove image_id as it is not needed in import
if (isset($params['image_id'])) {
unset($params['image_id']);
}
//convert params images:
if (isset($params["image"])) {
//import if exists in zip folder
if (strpos($params["image"], 'http') !== false) {
} else {
if (trim($params["image"]) !== '') {
if ($importZip === true) {
//we have a zip, check if exists
$image = $wp_filesystem->exists($d_path . 'images/' . $params["image"]);
if (!$image) {
echo $params["image"] . __(' not found!<br>', 'revslider');
} else {
if (!isset($alreadyImported['images/' . $params["image"]])) {
$importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $params["image"], $sliderParams["alias"] . '/');
if ($importImage !== false) {
$alreadyImported['images/' . $params["image"]] = $importImage['path'];
$params["image"] = $importImage['path'];
}
} else {
$params["image"] = $alreadyImported['images/' . $params["image"]];
}
}
}
}
$params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
}
}
//convert layers images:
foreach ($layers as $key => $layer) {
if (isset($layer["image_url"])) {
//import if exists in zip folder
if (trim($layer["image_url"]) !== '') {
if (strpos($layer["image_url"], 'http') !== false) {
} else {
if ($importZip === true) {
//we have a zip, check if exists
$image_url = $wp_filesystem->exists($d_path . 'images/' . $layer["image_url"]);
if (!$image_url) {
echo $layer["image_url"] . __(' not found!<br>');
} else {
if (!isset($alreadyImported['images/' . $layer["image_url"]])) {
$importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/');
if ($importImage !== false) {
$alreadyImported['images/' . $layer["image_url"]] = $importImage['path'];
$layer["image_url"] = $importImage['path'];
}