当前位置: 首页>>代码示例>>PHP>>正文


PHP cmb_Meta_Box::image_id_from_url方法代码示例

本文整理汇总了PHP中cmb_Meta_Box::image_id_from_url方法的典型用法代码示例。如果您正苦于以下问题:PHP cmb_Meta_Box::image_id_from_url方法的具体用法?PHP cmb_Meta_Box::image_id_from_url怎么用?PHP cmb_Meta_Box::image_id_from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cmb_Meta_Box的用法示例。


在下文中一共展示了cmb_Meta_Box::image_id_from_url方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file

 public function file()
 {
     $meta_value = $this->field->escaped_value();
     $allow = $this->field->args('allow');
     $input_type = 'url' == $allow || is_array($allow) && in_array('url', $allow) ? 'text' : 'hidden';
     echo $this->input(array('type' => $input_type, 'class' => 'cmb_upload_file', 'size' => 45, 'desc' => '')), '<input class="cmb_upload_button button" type="button" value="' . __('Add or Upload File', 'cmb') . '" />', $this->_desc(true);
     $cached_id = $this->_id();
     // Reset field args for attachment ID
     $args = $this->field->args();
     $args['id'] = $args['_id'] . '_id';
     unset($args['_id'], $args['_name']);
     // And get new field object
     $this->field = new cmb_Meta_Box_field($args, $this->field->group);
     // Get ID value
     $_id_value = $this->field->escaped_value('absint');
     // If there is no ID saved yet, try to get it from the url
     if ($meta_value && !$_id_value) {
         $_id_value = cmb_Meta_Box::image_id_from_url(esc_url_raw($meta_value));
     }
     echo $this->input(array('type' => 'hidden', 'class' => 'cmb_upload_file_id', 'value' => $_id_value, 'desc' => '')), '<div id="', $this->_id('_status'), '" class="cmb_media_status">';
     if (!empty($meta_value)) {
         if ($this->is_valid_img_ext($meta_value)) {
             echo '<div class="img_status">';
             echo '<img style="max-width: 350px; width: 100%; height: auto;" src="', $meta_value, '" alt="" />';
             echo '<p class="cmb_remove_wrapper"><a href="#" class="cmb_remove_file_button" rel="', $cached_id, '">' . __('Remove Image', 'cmb') . '</a></p>';
             echo '</div>';
         } else {
             // $file_ext = $this->get_file_ext( $meta_value );
             $parts = explode('/', $meta_value);
             for ($i = 0; $i < count($parts); ++$i) {
                 $title = $parts[$i];
             }
             echo __('File:', 'cmb'), ' <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta_value, '" target="_blank" rel="external">' . __('Download', 'cmb') . '</a> / <a href="#" class="cmb_remove_file_button" rel="', $cached_id, '">' . __('Remove', 'cmb') . '</a>)';
         }
     }
     echo '</div>';
 }
开发者ID:de190909,项目名称:WPTest,代码行数:37,代码来源:cmb_Meta_Box_types.php

示例2: _save_file_id

 /**
  * Peforms saving of `file` attachement's ID
  * @since  1.1.0
  * @param  string $value File url
  */
 public function _save_file_id($value)
 {
     $group = $this->field->group;
     $args = $this->field->args();
     $args['id'] = $args['_id'] . '_id';
     unset($args['_id'], $args['_name']);
     // And get new field object
     $field = new cmb_Meta_Box_field($args, $group);
     $id_key = $field->_id();
     $id_val_old = $field->escaped_value('absint');
     if ($group) {
         // Check group $_POST data
         $i = $group->index;
         $base_id = $group->_id();
         $id_val = isset($_POST[$base_id][$i][$id_key]) ? absint($_POST[$base_id][$i][$id_key]) : 0;
     } else {
         // Check standard $_POST data
         $id_val = isset($_POST[$field->id()]) ? $_POST[$field->id()] : null;
     }
     // If there is no ID saved yet, try to get it from the url
     if ($value && !$id_val) {
         $id_val = cmb_Meta_Box::image_id_from_url($value);
     }
     if ($group) {
         return array('attach_id' => $id_val, 'field_id' => $id_key);
     }
     if ($id_val && $id_val != $id_val_old) {
         return $field->update_data($id_val);
     } elseif (empty($id_val) && $id_val_old) {
         return $field->remove_data($old);
     }
 }
开发者ID:Kang8M,项目名称:gaonhat,代码行数:37,代码来源:cmb_Meta_Box_Sanitize.php

示例3: file

 public static function file($field, $meta, $object_id, $object_type)
 {
     $input_type_url = 'hidden';
     if ('url' == $field['allow'] || is_array($field['allow']) && in_array('url', $field['allow'])) {
         $input_type_url = 'text';
     }
     echo '<input class="cmb_upload_file" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />';
     echo '<input class="cmb_upload_button button" type="button" value="' . __('Add or Upload File', 'cmb') . '" />';
     $_id_name = $field['id'] . '_id';
     $_id_meta = get_metadata($object_type, $object_id, $_id_name, !isset($field['multiple']) || !$field['multiple']);
     // If there is no ID saved yet, try to get it from the url
     if ($meta && !$_id_meta) {
         $_id_meta = cmb_Meta_Box::image_id_from_url(esc_url_raw($meta));
     }
     echo '<input class="cmb_upload_file_id" type="hidden" id="', $_id_name, '" name="', $_id_name, '" value="', $_id_meta, '" />', self::desc($field['desc'], true), '<div id="', $field['id'], '_status" class="cmb_media_status">';
     if (!empty($meta)) {
         if (self::is_valid_img_ext($meta)) {
             echo '<div class="img_status">';
             echo '<img style="max-width: 350px; width: 100%; height: auto;" src="', $meta, '" alt="" />';
             echo '<p><a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">' . __('Remove Image', 'cmb') . '</a></p>';
             echo '</div>';
         } else {
             // $file_ext = self::get_file_ext( $meta );
             $parts = explode('/', $meta);
             for ($i = 0; $i < count($parts); ++$i) {
                 $title = $parts[$i];
             }
             echo __('File:', 'cmb'), ' <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta, '" target="_blank" rel="external">' . __('Download', 'cmb') . '</a> / <a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">' . __('Remove', 'cmb') . '</a>)';
         }
     }
     echo '</div>';
 }
开发者ID:PlanoBWeb,项目名称:BDA,代码行数:32,代码来源:cmb_Meta_Box_types.php

示例4: file

 /**
  * Sanitize code textareas
  * @since  1.0.2
  * @param  string $meta  Meta value
  * @param  array  $field Field config array
  * @return string        Sanitized data
  */
 public static function file($meta, $field)
 {
     $_id_name = $field['id'] . '_id';
     // get _id old value
     $_id_old = cmb_Meta_Box::get_data($_id_name);
     // If specified NOT to save the file ID
     if (isset($field['save_id']) && !$field['save_id']) {
         $_new_id = '';
     } else {
         // otherwise get the file ID
         $_new_id = isset($_POST[$_id_name]) ? $_POST[$_id_name] : null;
         // If there is no ID saved yet, try to get it from the url
         if (isset($_POST[$field['id']]) && $_POST[$field['id']] && !$_new_id) {
             $_new_id = cmb_Meta_Box::image_id_from_url(esc_url_raw($_POST[$field['id']]));
         }
     }
     if ($_new_id && $_new_id != $_id_old) {
         $updated[] = $_id_name;
         cmb_Meta_Box::update_data($_new_id, $_id_name);
     } elseif ('' == $_new_id && $_id_old) {
         $updated[] = $_id_name;
         cmb_Meta_Box::remove_data($_id_name, $old);
     }
     return self::default_sanitization($meta, $field);
 }
开发者ID:aguerojahannes,项目名称:aguerojahannes.com,代码行数:32,代码来源:cmb_Meta_Box_Sanitize.php


注:本文中的cmb_Meta_Box::image_id_from_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。