Community Forums › Forums › Archived Forums › General Discussion › Different image for mobile/tablet devices in custom loop
- This topic has 3 replies, 1 voice, and was last updated 9 years, 8 months ago by SirTzusky.
-
AuthorPosts
-
April 13, 2015 at 2:17 pm #147786SirTzuskyMember
Hello,
Can you please tell me if there is a way to serve different image for mobile/tablet devices in a genesis_custom_loop?
Thank you in advance.
P.S.: I want to use 'grid-thumbnail' for desktop and 'mobile-thumbnail' for mobile devices.
add_image_size('grid-thumbnail', 215, 135, true);
add_image_size('mobile-thumbnail', 300, 188, true);April 14, 2015 at 9:18 am #147866SirTzuskyMemberJust to make it clear:
I know how to use image sizes in WordPress. But I find it difficult to display different featured images for mobile devices in a custom loop with Genesis. I use a plugin to display different child theme for mobile devices, but everything I change in my loop the size of the image doesn't change. Below is the code I use for and works great for PC, but when I change grid-thumbnail with mobile-thumbnail, the image doesn't change (I have regenerate the images, so the 300x188 image is there) .
//* Add support for Genesis Grid Loop remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'child_grid_loop' ); function child_grid_loop() { //* Global vars global $_genesis_loop_args; //* Parse args $args = apply_filters( 'genesis_grid_loop_args', wp_parse_args( $args, array( 'grid_image_size' => 'grid-thumbnail', 'grid_image_class' => 'alignleft', 'grid_content_limit' => 0, 'more' => '', ) ) ); //* What page are we on? $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; //* Set global loop args $_genesis_loop_args = $args; //hooks and filters for remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 ); remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); //* The loop genesis_standard_loop(); //* Reset loops //genesis_reset_loops(); remove_filter( 'post_class', 'genesis_grid_loop_post_class' ); remove_action( 'genesis_post_content', 'genesis_grid_loop_content' ); remove_action( 'genesis_entry_content', 'genesis_grid_loop_content' ); }
Has something to do with the global $_genesis_loop_args; ?
Above is the main Loop. And I have template pages where I use custom_genesis_loop to display what I want.
Any ideas?
Thank you.April 16, 2015 at 1:36 pm #148153SirTzuskyMemberAnyone?
April 23, 2015 at 1:36 pm #148923SirTzuskyMemberI can work this out if someone can help me to change with code (in functions.php) the settings from the backend "Genesis / Theme Settings / Content Archives" ? For example the image size I want to be different than the one in the backend.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.