本文整理汇总了PHP中wp_make_content_images_responsive函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_make_content_images_responsive函数的具体用法?PHP wp_make_content_images_responsive怎么用?PHP wp_make_content_images_responsive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_make_content_images_responsive函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render_content
/**
* Renders the content for a builder layout while in the loop.
* This method should only be called by the_content filter as
* defined in fl-builder.php. To output builder content, use
* the_content function while in a WordPress loop.
*
* @since 1.0
* @param string $content The existing content.
* @return string
*/
public static function render_content($content)
{
$post_id = FLBuilderModel::get_post_id();
$enabled = FLBuilderModel::is_builder_enabled();
$rendering = $post_id === self::$post_rendering;
$ajax = defined('DOING_AJAX');
$in_loop = in_the_loop();
$is_global = in_array($post_id, FLBuilderModel::get_global_posts());
if ($enabled && !$rendering && !$ajax && ($in_loop || $is_global)) {
// Set the post rendering ID.
self::$post_rendering = $post_id;
// Remove the builder's render_content filter so it's not called again.
remove_filter('the_content', 'FLBuilder::render_content');
// Render the content.
ob_start();
echo '<div class="' . self::render_content_classes() . '" data-post-id="' . $post_id . '">';
self::render_nodes();
echo '</div>';
$content = ob_get_clean();
// Reapply the builder's render_content filter.
add_filter('the_content', 'FLBuilder::render_content');
// Do shortcodes here since letting the WP filter run can cause an infinite loop.
$pattern = get_shortcode_regex();
$content = preg_replace_callback("/{$pattern}/s", 'FLBuilder::double_escape_shortcodes', $content);
$content = do_shortcode($content);
// Add srcset attrs to images with the class wp-image-<ID>.
if (function_exists('wp_make_content_images_responsive')) {
$content = wp_make_content_images_responsive($content);
}
// Clear the post rendering ID.
self::$post_rendering = null;
}
return $content;
}
开发者ID:komcdo,项目名称:iSSNA-WordPress,代码行数:44,代码来源:class-fl-builder.php
示例2: get_template_variables
public function get_template_variables($instance, $args)
{
$instance = wp_parse_args($instance, array('text' => ''));
$instance['text'] = $this->unwpautop($instance['text']);
$instance['text'] = apply_filters('widget_text', $instance['text']);
// Run some known stuff
if (!empty($GLOBALS['wp_embed'])) {
$instance['text'] = $GLOBALS['wp_embed']->autoembed($instance['text']);
}
if (function_exists('wp_make_content_images_responsive')) {
$instance['text'] = wp_make_content_images_responsive($instance['text']);
}
if ($instance['autop']) {
$instance['text'] = wpautop($instance['text']);
}
$instance['text'] = do_shortcode(shortcode_unautop($instance['text']));
return array('text' => $instance['text']);
}
开发者ID:KJaddoe,项目名称:CSCMRA-Project,代码行数:18,代码来源:editor.php
示例3: test_wp_make_content_images_responsive_with_preexisting_srcset
/**
* @ticket 33641
*/
function test_wp_make_content_images_responsive_with_preexisting_srcset()
{
// Generate HTML and add a dummy srcset attribute.
$image_html = get_image_tag(self::$large_id, '', '', '', 'medium');
$image_html = preg_replace('|<img ([^>]+) />|', '<img $1 ' . 'srcset="image2x.jpg 2x" />', $image_html);
// The content filter should return the image unchanged.
$this->assertSame($image_html, wp_make_content_images_responsive($image_html));
}
开发者ID:nkeat12,项目名称:dv,代码行数:11,代码来源:media.php
示例4: before_the_title
function before_the_title()
{
$post = get_post();
if (isset($post->post_title_img)) {
echo wp_make_content_images_responsive($post->post_title_img);
}
}
开发者ID:emutavchi,项目名称:WebKitForWayland,代码行数:7,代码来源:functions.php
示例5: prepare_output
/**
* prepare the ads frontend output
*
* @param obj $ad ad object
* @return str $content ad content prepared for frontend output
* @since 1.0.0
*/
public function prepare_output($ad)
{
// apply functions normally running through the_content filter
// the_content filter is not used here because it created an infinite loop (ads within ads for "before content" and other auto injections)
// maybe the danger is not here yet, but changing it to use the_content filter changes a lot
$output = $ad->content;
$output = wptexturize($output);
$output = convert_smilies($output);
$output = convert_chars($output);
$output = wpautop($output);
$output = shortcode_unautop($output);
$output = do_shortcode($output);
$output = prepend_attachment($output);
// make included images responsive, since WordPress 4.4
if (!defined('ADVADS_DISABLE_RESPONSIVE_IMAGES') && function_exists('wp_make_content_images_responsive')) {
$output = wp_make_content_images_responsive($output);
}
return $output;
}
开发者ID:bruno-barros,项目名称:w.eloquent.light,代码行数:26,代码来源:ad_type_content.php
示例6: test_wp_make_content_images_responsive_schemes
function test_wp_make_content_images_responsive_schemes()
{
$image_meta = wp_get_attachment_metadata(self::$large_id);
$size_array = array((int) $image_meta['sizes']['medium']['width'], (int) $image_meta['sizes']['medium']['height']);
$srcset = sprintf('srcset="%s"', wp_get_attachment_image_srcset(self::$large_id, $size_array, $image_meta));
$sizes = sprintf('sizes="%s"', wp_get_attachment_image_sizes(self::$large_id, $size_array, $image_meta));
// Build HTML for the editor.
$img = get_image_tag(self::$large_id, '', '', '', 'medium');
$img_https = str_replace('http://', 'https://', $img);
$img_relative = str_replace('http://', '//', $img);
// Manually add srcset and sizes to the markup from get_image_tag();
$respimg = preg_replace('|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img);
$respimg_https = preg_replace('|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_https);
$respimg_relative = preg_replace('|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_relative);
$content = '
<p>Image, http: protocol. Should have srcset and sizes.</p>
%1$s
<p>Image, http: protocol. Should have srcset and sizes.</p>
%2$s
<p>Image, protocol-relative. Should have srcset and sizes.</p>
%3$s';
$unfiltered = sprintf($content, $img, $img_https, $img_relative);
$expected = sprintf($content, $respimg, $respimg_https, $respimg_relative);
$actual = wp_make_content_images_responsive($unfiltered);
$this->assertSame($expected, $actual);
}
开发者ID:barkinet,项目名称:wp-tevko-responsive-images,代码行数:28,代码来源:test-suite.php
示例7: genesis_do_post_image
/**
* Echo the post image on archive pages.
*
* If this an archive page and the option is set to show thumbnail, then it gets the image size as per the theme
* setting, wraps it in the post permalink and echoes it.
*
* @since 1.1.0
*/
function genesis_do_post_image()
{
if (!is_singular() && genesis_get_option('content_archive_thumbnail')) {
$img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'context' => 'archive', 'attr' => genesis_parse_attr('entry-image', array('alt' => get_the_title()))));
if (!empty($img)) {
genesis_markup(array('open' => '<a %s>', 'close' => '</a>', 'content' => wp_make_content_images_responsive($img), 'context' => 'entry-image-link'));
}
}
}
开发者ID:netmagik,项目名称:netmagik,代码行数:17,代码来源:post.php
示例8: wp_get_attachment_metadata
<?php
$attachment_data = wp_get_attachment_metadata($attachment_id);
?>
<?php
if (is_array($attachment_data)) {
?>
<li>
<div class="fusion-image-wrapper">
<a href="<?php
the_permalink();
?>
">
<?php
$image_markup = sprintf('<img src="%s" alt="%s" class="wp-image-%s" role="presentation"/>', $attachment_image[0], $attachment_data['image_meta']['title'], $attachment_id);
$image_markup = Avada()->images->edit_grid_image_src($image_markup, get_the_ID(), $attachment_id, $size);
echo wp_make_content_images_responsive($image_markup);
?>
</a>
<a style="display:none;" href="<?php
echo $full_image[0];
?>
" data-rel="iLightbox[gallery<?php
echo $post->ID;
?>
]" title="<?php
echo get_post_field('post_excerpt', $attachment_id);
?>
" data-title="<?php
echo get_post_field('post_title', $attachment_id);
?>
" data-caption="<?php
开发者ID:pedrom40,项目名称:sazoo.org,代码行数:31,代码来源:new-slideshow.php
示例9: tevkori_filter_content_images
/**
* Filter to add 'srcset' and 'sizes' attributes to images in the post content.
*
* @since 2.5.0
* @deprecated 3.0.0 Use 'wp_make_content_images_responsive()'
*
* @see wp_make_content_images_responsive()
*
* @param string $content The raw post content to be filtered.
* @return string Converted content with 'srcset' and 'sizes' added to images.
*/
function tevkori_filter_content_images($content)
{
_deprecated_function(__FUNCTION__, '3.0.0', 'wp_make_content_images_responsive()');
return wp_make_content_images_responsive($content);
}
开发者ID:mrakotomizao,项目名称:azuretest,代码行数:16,代码来源:wp-tevko-deprecated-functions.php
示例10: widget
/**
* Echo the widget content.
*
* @since 0.1.8
*
* @global WP_Query $wp_query Query object.
* @global array $_genesis_displayed_ids Array of displayed post IDs.
* @global int $more
*
* @param array $args Display arguments including `before_title`, `after_title`,
* `before_widget`, and `after_widget`.
* @param array $instance The settings for the particular instance of the widget.
*/
function widget($args, $instance)
{
global $wp_query, $_genesis_displayed_ids;
// Merge with defaults.
$instance = wp_parse_args((array) $instance, $this->defaults);
echo $args['before_widget'];
// Set up the author bio.
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
}
$query_args = array('post_type' => 'post', 'cat' => $instance['posts_cat'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'ignore_sticky_posts' => $instance['exclude_sticky']);
// Exclude displayed IDs from this loop?
if ($instance['exclude_displayed']) {
$query_args['post__not_in'] = (array) $_genesis_displayed_ids;
}
$wp_query = new WP_Query($query_args);
if (have_posts()) {
while (have_posts()) {
the_post();
$_genesis_displayed_ids[] = get_the_ID();
genesis_markup(array('open' => '<article %s>', 'context' => 'entry'));
$image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget', array('alt' => get_the_title()))));
if ($instance['show_image'] && $image) {
$role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
printf('<a href="%s" class="%s" %s>%s</a>', get_permalink(), esc_attr($instance['image_alignment']), $role, wp_make_content_images_responsive($image));
}
if (!empty($instance['show_gravatar'])) {
echo '<span class="' . esc_attr($instance['gravatar_alignment']) . '">';
echo get_avatar(get_the_author_meta('ID'), $instance['gravatar_size']);
echo '</span>';
}
if ($instance['show_title'] || $instance['show_byline']) {
$header = '';
if (!empty($instance['show_title'])) {
$title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
/**
* Filter the featured post widget title.
*
* @since 2.2.0
*
* @param string $title Featured post title.
* @param array $instance {
* Widget settings for this instance.
*
* @type string $title Widget title.
* @type int $posts_cat ID of the post category.
* @type int $posts_num Number of posts to show.
* @type int $posts_offset Number of posts to skip when
* retrieving.
* @type string $orderby Field to order posts by.
* @type string $order ASC fr ascending order, DESC for
* descending order of posts.
* @type bool $exclude_displayed True if posts shown in main output
* should be excluded from this widget
* output.
* @type bool $show_image True if featured image should be
* shown, false otherwise.
* @type string $image_alignment Image alignment: alignnone,
* alignleft, aligncenter or alignright.
* @type string $image_size Name of the image size.
* @type bool $show_gravatar True if author avatar should be
* shown, false otherwise.
* @type string $gravatar_alignment Author avatar alignment: alignnone,
* alignleft or aligncenter.
* @type int $gravatar_size Dimension of the author avatar.
* @type bool $show_title True if featured page title should
* be shown, false otherwise.
* @type bool $show_byline True if post info should be shown,
* false otherwise.
* @type string $post_info Post info contents to show.
* @type bool $show_content True if featured page content
* should be shown, false otherwise.
* @type int $content_limit Amount of content to show, in
* characters.
* @type int $more_text Text to use for More link.
* @type int $extra_num Number of extra post titles to show.
* @type string $extra_title Heading for extra posts.
* @type bool $more_from_category True if showing category archive
* link, false otherwise.
* @type string $more_from_category_text Category archive link text.
* }
* @param array $args {
* Widget display arguments.
*
* @type string $before_widget Markup or content to display before the widget.
* @type string $before_title Markup or content to display before the widget title.
* @type string $after_title Markup or content to display after the widget title.
//.........这里部分代码省略.........
开发者ID:netmagik,项目名称:netmagik,代码行数:101,代码来源:featured-post-widget.php
示例11: create_contact_maps
//.........这里部分代码省略.........
if(screen_width <= 750 && screen_width >= 481 ){
grid_view_col = 2;
}
jQuery('.people_box_content<?php
echo $unique_id;
?>
').imagesLoaded(function(){
jQuery('.people_box_content<?php
echo $unique_id;
?>
').masonry({
itemSelector: '.people_item<?php
echo $unique_id;
?>
',
<?php
if (version_compare($cur_wp_version, '3.9', '<')) {
?>
columnWidth: jQuery('.people_box_content<?php
echo $unique_id;
?>
').width()/grid_view_col
<?php
} else {
?>
columnWidth: '.people-grid-sizer'
<?php
}
?>
});
});
});
</script>
<?php
$html = '';
if ($show_map != 0) {
$html .= '<div style="clear:both"></div>';
$html .= '<div class="people-entry">';
$html .= '<div style="clear:both"></div>';
$html .= '<div id="map_canvas' . $unique_id . '" class="map_canvas_container" style="width: ' . $map_width . $map_width_type . '; height: ' . $map_height . 'px;float:left;"></div>';
$html .= '<div style="clear:both;margin-bottom:0em;" class="custom_title"></div>';
$html .= '<div style="clear:both;height:15px;"></div>';
$html .= '</div>';
}
$grid_view_team_title = trim($people_contact_global_settings['grid_view_team_title']);
if ($grid_view_team_title != '') {
$html .= '<div class="custom_box_title"><h1 class="p_title">' . $grid_view_team_title . '</h1></div>';
}
$html .= '<div style="clear:both;margin-bottom:1em;"></div>';
$html .= '<div class="people_box_content people_box_content' . $unique_id . ' pcol' . $grid_view_col . '"><div class="people-grid-sizer"></div>';
if (is_array($contacts) && count($contacts) > 0) {
foreach ($contacts as $key => $value) {
if ($value['c_avatar'] != '') {
$src = $value['c_avatar'];
$c_attachment_id = $value['c_attachment_id'];
} else {
$src = PEOPLE_CONTACT_IMAGE_URL . '/no-avatar.png';
$c_attachment_id = 0;
}
$html .= '<div class="people_item people_item' . $unique_id . ' people_item_id' . $value['id'] . '">';
$html .= '<div class="people-entry-item">';
$html .= '<div style="clear:both;"></div>';
$html .= '<div class="people-content-item">';
$img_output = '<img class="wp-image-' . $c_attachment_id . '" src="' . $src . '" />';
if (function_exists('wp_make_content_images_responsive')) {
$img_output = wp_make_content_images_responsive($img_output);
}
$html .= '<h3 class="p_item_title">' . esc_attr(stripslashes($value['c_title'])) . '</h3>';
$html .= '<div class="p_content_left">' . $img_output . '</div>';
$html .= '<div class="p_content_right">';
$html .= '<h3 class="p_item_name">' . esc_attr(stripslashes($value['c_name'])) . '</h3>';
if (trim($value['c_about']) != '') {
$html .= wpautop(wptexturize(stripslashes($value['c_about'])));
}
if (trim($value['c_phone']) != '') {
$html .= '<p style="margin-bottom:5px;"><span class="p_icon_phone"><img src="' . $phone_icon . '" style="width:auto;height:auto" /></span> ' . esc_attr(stripslashes($value['c_phone'])) . '</p>';
}
if (trim($value['c_fax']) != '') {
$html .= '<p style="margin-bottom:5px;"><span class="p_icon_fax"><img src="' . $fax_icon . '" style="width:auto;height:auto" /></span> ' . esc_attr(stripslashes($value['c_fax'])) . '</p>';
}
if (trim($value['c_mobile']) != '') {
$html .= '<p style="margin-bottom:5px;"><span class="p_icon_mobile"><img src="' . $mobile_icon . '" style="width:auto;height:auto" /></span> ' . esc_attr(stripslashes($value['c_mobile'])) . '</p>';
}
if (trim($value['c_website']) != '') {
$html .= '<p style="margin-bottom:5px;"><span class="p_icon_website"><img src="' . $website_icon . '" style="width:auto;height:auto" /></span> <a href="' . esc_url(stripslashes($value['c_website'])) . '" target="_blank">' . (function_exists('icl_t') ? icl_t('a3 Contact People', 'Profile Cards - Website Link Text', __('Visit Website', 'cup_cp')) : __('Visit Website', 'cup_cp')) . '</a></p>';
}
if (trim($value['c_email']) != '') {
$html .= '<p style="margin-bottom:0px;"><span class="p_icon_email"><img src="' . $email_icon . '" style="width:auto;height:auto" /></span> <a style="cursor:pointer" class="direct_email direct_email' . $unique_id . '" profile-id="' . $value['id'] . '" href="#' . $value['id'] . '">' . (function_exists('icl_t') ? icl_t('a3 Contact People', 'Profile Cards - Email Link Text', __('Click Here', 'cup_cp')) : __('Click Here', 'cup_cp')) . '</a></p>';
}
$html .= '</div>';
$html .= '</div>';
$html .= '<div style="clear:both;"></div>';
$html .= '</div>';
$html .= '</div>';
}
}
$html .= '</div>';
$html .= '<div style="clear:both"></div>';
return $html;
}
开发者ID:jep-heroes,项目名称:wp,代码行数:101,代码来源:class-people-contact.php
示例12: gently_featured_image
/**
* Prints HTML with post's featured image.
*
* @param bool $skip Skips the image wrapper class.
*/
function gently_featured_image($skip = false)
{
if (has_post_thumbnail()) {
if ($skip) {
echo '<div>';
} else {
if (!is_single() && !is_page()) {
echo '<div class="entry-image">';
} else {
echo '<div class="featured-image">';
}
}
$image = sprintf('<a href="%s" title="%s">' . get_the_post_thumbnail() . '</a>', get_the_permalink(), the_title_attribute('echo=0'));
// Add srcset and sizes to image in WordPress >= 4.4
if (function_exists('wp_make_content_images_responsive')) {
echo wp_make_content_images_responsive($image);
} else {
echo $image;
}
echo '</div>';
}
}
开发者ID:Greg36,项目名称:Gently,代码行数:27,代码来源:template-tags.php
示例13: widget
/**
* Echo the widget content.
*
* @since 0.1.8
*
* @global WP_Query $wp_query Query object.
* @global int $more
*
* @param array $args Display arguments including `before_title`, `after_title`,
* `before_widget`, and `after_widget`.
* @param array $instance The settings for the particular instance of the widget.
*/
function widget($args, $instance)
{
global $wp_query;
// Merge with defaults.
$instance = wp_parse_args((array) $instance, $this->defaults);
echo $args['before_widget'];
// Set up the author bio.
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
}
$wp_query = new WP_Query(array('page_id' => $instance['page_id']));
if (have_posts()) {
while (have_posts()) {
the_post();
genesis_markup(array('open' => '<article %s>', 'context' => 'entry'));
$image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-page-widget', 'attr' => genesis_parse_attr('entry-image-widget', array('alt' => get_the_title()))));
if ($instance['show_image'] && $image) {
$role = empty($instance['show_title']) ? '' : 'aria-hidden="true"';
printf('<a href="%s" class="%s" %s>%s</a>', get_permalink(), esc_attr($instance['image_alignment']), $role, wp_make_content_images_responsive($image));
}
if (!empty($instance['show_title'])) {
$title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
/**
* Filter the featured page widget title.
*
* @since 2.2.0
*
* @param string $title Featured page title.
* @param array $instance {
* Widget settings for this instance.
*
* @type string $title Widget title.
* @type int $page_id ID of the featured page.
* @type bool $show_image True if featured image should be shown, false
* otherwise.
* @type string $image_alignment Image alignment: alignnone, alignleft,
* aligncenter or alignright.
* @type string $image_size Name of the image size.
* @type bool $show_title True if featured page title should be shown,
* false otherwise.
* @type bool $show_content True if featured page content should be shown,
* false otherwise.
* @type int $content_limit Amount of content to show, in characters.
* @type int $more_text Text to use for More link.
* }
* @param array $args {
* Widget display arguments.
*
* @type string $before_widget Markup or content to display before the widget.
* @type string $before_title Markup or content to display before the widget title.
* @type string $after_title Markup or content to display after the widget title.
* @type string $after_widget Markup or content to display after the widget.
* }
*/
$title = apply_filters('genesis_featured_page_title', $title, $instance, $args);
$heading = genesis_a11y('headings') ? 'h4' : 'h2';
genesis_markup(array('open' => "<header class=\"entry-header\"><{$heading} class=\"entry-title\">", 'close' => "</{$heading}></header>", 'context' => 'widget-entry-title', 'content' => sprintf('<a href="%s">%s</a>', get_permalink(), $title)));
}
if (!empty($instance['show_content'])) {
genesis_markup(array('open' => '<div %s>', 'context' => 'entry-content'));
if (empty($instance['content_limit'])) {
global $more;
$orig_more = $more;
$more = 0;
the_content(genesis_a11y_more_link($instance['more_text']));
$more = $orig_more;
} else {
the_content_limit((int) $instance['content_limit'], genesis_a11y_more_link(esc_html($instance['more_text'])));
}
genesis_markup(array('close' => '</div>', 'context' => 'entry-content'));
}
genesis_markup(array('close' => '</article>', 'context' => 'entry'));
}
}
// Restore original query.
wp_reset_query();
echo $args['after_widget'];
}
开发者ID:netmagik,项目名称:netmagik,代码行数:90,代码来源:featured-page-widget.php
注:本文中的wp_make_content_images_responsive函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论