{"id":36165,"date":"2013-12-22T23:05:39","date_gmt":"2013-12-22T22:05:39","guid":{"rendered":"https:\/\/pl.wordpress.org\/support\/topic\/dopasowanie-zdjec-do-rozmiaru-slidera\/"},"modified":"2016-08-05T22:03:45","modified_gmt":"2016-08-05T22:03:45","slug":"dopasowanie-zdjec-do-rozmiaru-slidera","status":"closed","type":"topic","link":"https:\/\/pl.wordpress.org\/support\/topic\/dopasowanie-zdjec-do-rozmiaru-slidera\/","title":{"rendered":"Dopasowanie zdj\u0119\u0107 do rozmiaru slidera"},"content":{"rendered":"<p>Witam,<\/p>\n<p>u\u017cywam szablonu Graphene i nie mog\u0119 poradzi\u0107 sobie z dopasowaniem rozmiaru zdj\u0119cia do slidera. Je\u015bli ustawi\u0119 opcj\u0119 &#8222;pierwszy obrazek we wpisie, to slider wycina i pokazuje prawy g\u00f3rny r\u00f3g (czyli np. ca\u0142\u0105 jego powierzchni\u0119 zajmuje niebo)<\/p>\n<p>Moja strona: www.szwendalus.pl<\/p>\n<p>Plik theme-slider.php wygl\u0105da tak<\/p>\n<pre><code>&lt;?php\nglobal $graphene_settings;\n\/**\n * Creates the functions that output the slider\n*\/\nfunction graphene_slider(){\n\tglobal $graphene_settings, $graphene_in_slider;\n\n\t$graphene_in_slider = true;\n\tif ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;bgimage-excerpt&#039; )\n\t\tgraphene_set_excerpt_length( 35 );\n\n\tdo_action( &#039;graphene_before_slider&#039; ); ?&gt;\n    &lt;?php\n\t\t\/* Generate classes for the slider wrapper *\/\n\t\t$class = array( &#039;featured_slider&#039;, &#039;clearfix&#039; );\n\t\t$class[] = $graphene_settings[&#039;slider_display_style&#039;];\n\t\t$class[] = $graphene_settings[&#039;slider_animation&#039;];\n\n\t\t\/* For backward compatibility *\/\n\t\tif ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;bgimage-excerpt&#039; )\n\t\t\t$class[] = &#039;full-sized&#039;;\n\n\t\t$class = apply_filters( &#039;graphene_slider_class&#039;, $class );\n\t\t$class = implode( &#039; &#039;, $class );\n\t?&gt;\n    &lt;div class=&quot;&lt;?php echo $class; ?&gt;&quot;&gt;\n\t    &lt;?php do_action( &#039;graphene_before_slider_root&#039; ); ?&gt;\n        &lt;div id=&quot;slider_root&quot; class=&quot;clearfix&quot;&gt;\n       \t\t&lt;?php do_action( &#039;graphene_before_slideritems&#039; ); ?&gt;\n\t        &lt;div class=&quot;slider_items&quot;&gt;\n\t    &lt;?php\n        \/* Get the posts to be displayed *\/\n\t\t$sliderposts = graphene_get_slider_posts();\n\n        \/* Display each post in the slider *\/\n        $slidernav_html = &#039;&#039;;\n        $i = 0;\n        while ( $sliderposts-&gt;have_posts() ) : $sliderposts-&gt;the_post();\n\n\t\t\t$style = &#039;&#039;;\n\t\t\t\/* Slider background image*\/\n\t\t\tif ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;bgimage-excerpt&#039; ) {\n\t\t\t\t\t$image = graphene_get_slider_image( get_the_ID(), &#039;graphene_slider&#039;, true);\n\t\t\t\t\tif ( $image ){\n\t\t\t\t\t\t\t$style .= &#039;style=&quot;background-image:url(&#039;;\n\t\t\t\t\t\t\t$style .= ( is_array( $image ) ) ? $image[0] : $image;\n\t\t\t\t\t\t\t$style .= &#039;);&quot;&#039;;\n\t\t\t\t\t}\n\t\t\t}\n\n\t\t\t$slider_link_url = esc_url( graphene_get_post_meta( get_the_ID(), &#039;slider_url&#039; ) );\n\t\t\tif ( ! $slider_link_url )\n\t\t\t\t$slider_link_url = get_permalink();\n\n\t\t\t$slider_link_url = apply_filters( &#039;graphene_slider_link_url&#039;, $slider_link_url, get_the_ID() );\n\t\t\t?&gt;\n\n            &lt;div &lt;?php graphene_grid( &#039;slider_post clearfix&#039;, 16, 11, 8, true, true ); ?&gt; id=&quot;slider-post-&lt;?php the_ID(); ?&gt;&quot; &lt;?php echo $style; ?&gt;&gt;\n                &lt;?php do_action( &#039;graphene_before_sliderpost&#039; ); ?&gt;\n\n                &lt;?php if ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;bgimage-excerpt&#039; ) : ?&gt;\n                \t&lt;a href=&quot;&lt;?php echo $slider_link_url; ?&gt;&quot; class=&quot;permalink-overlay&quot;&gt;&lt;span&gt;&lt;?php _e( &#039;View full post&#039;, &#039;graphene&#039; ); ?&gt;&lt;\/span&gt;&lt;\/a&gt;\n                &lt;?php endif; ?&gt;\n\n                &lt;?php if ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;thumbnail-excerpt&#039; ) : ?&gt;\n\t\t\t\t\t&lt;?php \/* The slider post&#039;s featured image *\/ ?&gt;\n                    &lt;?php\n\t\t\t\t\t$slider_img_setting = graphene_get_post_meta( get_the_ID(), &#039;slider_img&#039; );\n                    if ( $slider_img_setting != &#039;disabled&#039; &amp;&amp; ! ( ( $slider_img_setting == &#039;global&#039; || $slider_img_setting == &#039;&#039; ) &amp;&amp; $graphene_settings[&#039;slider_img&#039;] == &#039;disabled&#039; ) ) :\n\t\t\t\t\t\t$image = graphene_get_slider_image( get_the_ID(), apply_filters( &#039;graphene_slider_image_size&#039;, &#039;thumbnail&#039; ) );\n\t\t\t\t\t\tif ( $image ) :\n\t\t\t\t\t\t?&gt;\n\t\t\t\t\t\t&lt;div class=&quot;sliderpost_featured_image&quot;&gt;\n\t\t\t\t\t\t\t&lt;a href=&quot;&lt;?php echo $slider_link_url; ?&gt;&quot;&gt;&lt;?php echo $image; ?&gt;&lt;\/a&gt;\n\t\t\t\t\t\t&lt;\/div&gt;\n                    &lt;?php endif; endif; ?&gt;\n                &lt;?php endif; ?&gt;\n\n                &lt;div class=&quot;slider-entry-wrap clearfix&quot;&gt;\n                \t&lt;div class=&quot;slider-content-wrap&quot;&gt;\n\t\t\t\t\t\t&lt;?php \/* The slider post&#039;s title *\/ ?&gt;\n                        &lt;h2 class=&quot;slider_post_title&quot;&gt;&lt;a href=&quot;&lt;?php echo $slider_link_url; ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/h2&gt;\n\n                        &lt;?php \/* The slider post&#039;s excerpt *\/ ?&gt;\n                        &lt;div class=&quot;slider_post_entry clearfix&quot;&gt;\n                        \t&lt;?php\n\t\t\t\t\t\t\tif ( $graphene_settings[&#039;slider_display_style&#039;] != &#039;full-post&#039; ){\n\t\t\t\t\t\t\t\tthe_excerpt();\n\t\t\t\t\t\t\t?&gt;\n                            &lt;?php if ( $graphene_settings[&#039;slider_display_style&#039;] == &#039;thumbnail-excerpt&#039; ) : ?&gt;\n                            \t&lt;a class=&quot;block-button&quot; href=&quot;&lt;?php echo $slider_link_url; ?&gt;&quot;&gt;&lt;?php _e( &#039;View full post&#039;, &#039;graphene&#039; ); ?&gt;&lt;\/a&gt;\n                            &lt;?php endif; ?&gt;\n                            &lt;?php } else { the_content(); }?&gt;\n\n                            &lt;?php do_action( &#039;graphene_slider_postentry&#039; ); ?&gt;\n                        &lt;\/div&gt;\n                    &lt;\/div&gt;\n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;?php\n            $slidernav_html .= &#039;&lt;a href=&quot;#&quot;&#039;. ( $i == 0 ? &#039; class=&quot;active&quot;&#039; : &#039;&#039; ) .&#039;&gt;&lt;span&gt;&#039;. get_the_title(). &#039;&lt;\/span&gt;&lt;\/a&gt;&#039;;\n            $i++;\n        endwhile;\n        wp_reset_postdata();\n    ?&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n\n        &lt;?php \/* The slider navigation *\/ ?&gt;\n        &lt;div class=&quot;slider_nav&quot;&gt;\n            &lt;?php echo $slidernav_html; ?&gt;\n            &lt;?php do_action( &#039;graphene_slider_nav&#039; ); ?&gt;\n        &lt;\/div&gt;\n\n    &lt;\/div&gt;\n    &lt;?php\n\tdo_action( &#039;graphene_after_slider&#039; );\n\n\tgraphene_reset_excerpt_length();\n\t$graphene_in_slider = false;\n}\n\n\/**\n * Create an intermediate function that controls where the slider should be displayed\n *\/\nif ( ! function_exists( &#039;graphene_display_slider&#039; ) ) :\n\tfunction graphene_display_slider(){\n\t\tif ( is_front_page() ){\n\t\t\tgraphene_slider();\n\t\t}\n\t}\nendif;\n\n\/**\n * Hook the slider to the appropriate action hook\n *\/\nif ( ! $graphene_settings[&#039;slider_disable&#039;] ){\n\tif ( ! $graphene_settings[&#039;slider_position&#039;] ) {\n\t\tif ( $graphene_settings[&#039;slider_full_width&#039;] )\n\t\t\tadd_action( &#039;graphene_before_content-main&#039;, &#039;graphene_display_slider&#039; );\n\t\telse\n\t\t\tadd_action( &#039;graphene_top_content&#039;, &#039;graphene_display_slider&#039; );\n\t} else {\n\t\tif ( $graphene_settings[&#039;slider_full_width&#039;] )\n\t\t\tadd_action( &#039;graphene_after_content&#039;, &#039;graphene_display_slider&#039; );\n\t\telse\n\t\t\tadd_action( &#039;graphene_bottom_content&#039;, &#039;graphene_display_slider&#039;, 11 );\n\t}\n}\n\nif ( ! function_exists( &#039;graphene_get_slider_image&#039; ) ) :\n\/**\n * This function determines which image to be used as the slider image based on user\n * settings, and returns the &lt;img&gt; tag of the the slider image.\n *\n * It requires the post&#039;s ID to be passed in as argument so that the user settings in\n * individual post \/ page can be retrieved.\n*\/\nfunction graphene_get_slider_image( $post_id = NULL, $size = &#039;thumbnail&#039;, $urlonly = false, $default = &#039;&#039; ){\n\tglobal $graphene_settings;\n\n\t\/\/ Throw an error message if no post ID supplied\n\tif ( $post_id == NULL){\n\t\techo &#039;&lt;strong&gt;ERROR:&lt;\/strong&gt; Post ID must be passed as an input argument to call the function &lt;code&gt;graphene_get_slider_image()&lt;\/code&gt;.&#039;;\n\t\treturn;\n\t}\n\n\t\/\/ First get the settings\n\t$global_setting = ( $graphene_settings[&#039;slider_img&#039;] ) ? $graphene_settings[&#039;slider_img&#039;] : &#039;featured_image&#039;;\n\t$local_setting = graphene_get_post_meta( $post_id, &#039;slider_img&#039; );\n\t$local_setting = ( $local_setting ) ? $local_setting : &#039;&#039;;\n\n\t\/\/ Determine which image should be displayed\n\t$final_setting = ( $local_setting == &#039;&#039; ) ? $global_setting : $local_setting;\n\n\t\/\/ Build the html based on the final setting\n\t$html = &#039;&#039;;\n\tif ( $final_setting == &#039;disabled&#039; ){\t\t\t\t\t\/\/ image disabled\n\n\t\treturn false;\n\n\t} elseif ( $final_setting == &#039;featured_image&#039; ){\t\t\/\/ Featured Image\n\n\t\tif ( has_post_thumbnail( $post_id ) ) :\n\t\t\tif ( $urlonly )\n\t\t\t\t$html = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size );\n\t\t\telse\n\t\t\t\t$html .= get_the_post_thumbnail( $post_id, $size );\n\t\tendif;\n\n\t} elseif ( $final_setting == &#039;post_image&#039; ){\t\t\t\/\/ First image in post\n\n\t\t\t$html = graphene_get_post_image( $post_id, $size, &#039;&#039;, $urlonly);\n\n\t} elseif ( $final_setting == &#039;custom_url&#039; ){\t\t\t\/\/ Custom URL\n\n\t\tif ( ! $urlonly ){\n\t\t\t$html .= &#039;&#039;;\n\t\t\tif ( $local_setting != &#039;&#039; ) :\n\t\t\t\t$html .= &#039;&lt;img src=&quot;&#039; . esc_url( graphene_get_post_meta( $post_id, &#039;slider_imgurl&#039; ) ) . &#039;&quot; alt=&quot;&quot; \/&gt;&#039;;\n\t\t\telse :\n\t\t\t\t$html .= &#039;&lt;img src=&quot;&#039; . esc_url( $graphene_settings[&#039;slider_imgurl&#039;] ) . &#039;&quot; alt=&quot;&quot; \/&gt;&#039;;\n\t\t\tendif;\n\t\t} else {\n\t\t\tif ( $local_setting != &#039;&#039; ) :\n\t\t\t\t$html .= esc_url( graphene_get_post_meta( $post_id, &#039;slider_imgurl&#039; ) );\n\t\t\telse :\n\t\t\t\t$html .= esc_url(  $graphene_settings[&#039;slider_imgurl&#039;] );\n\t\t\tendif;\n\t\t}\n\n\t}\n\n\tif ( ! $html )\n\t\t$html = $default;\n\n\t\/\/ Returns the html\n\treturn $html;\n\n}\nendif;\n\n\/**\n * Returns the posts to be displayed in the slider\n *\n * @return object Object containing the slider posts\n\n * @package Graphene\n * @since 1.6\n*\/\nif ( ! function_exists( &#039;graphene_get_slider_posts&#039; ) ) :\n\nfunction graphene_get_slider_posts(){\n\tglobal $graphene_settings;\n\n\t\/* Get the category whose posts should be displayed here. *\/\n\t$slidertype = ( $graphene_settings[&#039;slider_type&#039;] != &#039;&#039; ) ? $graphene_settings[&#039;slider_type&#039;] : false;\n\n\t\/* Set the post types to be displayed *\/\n\t$slider_post_type = ( in_array( $slidertype, array( &#039;posts_pages&#039;, &#039;categories&#039; ) ) ) ? array( &#039;post&#039;, &#039;page&#039; ) : array( &#039;post&#039; ) ;\n\t$slider_post_type = apply_filters( &#039;graphene_slider_post_type&#039;, $slider_post_type );\n\n\t\/* Get the number of posts to show *\/\n\t$postcount = ( $graphene_settings[&#039;slider_postcount&#039;] ) ? $graphene_settings[&#039;slider_postcount&#039;] : 5 ;\n\n\t$args = array(\n\t\t\t\t&#039;posts_per_page&#039;\t=&gt; $postcount,\n\t\t\t\t&#039;orderby&#039; \t\t\t=&gt; &#039;menu_order date&#039;,\n\t\t\t\t&#039;order&#039; \t\t\t=&gt; &#039;DESC&#039;,\n\t\t\t\t&#039;suppress_filters&#039; \t=&gt; 0,\n\t\t\t\t&#039;post_type&#039; \t\t=&gt; $slider_post_type,\n\t\t\t\t&#039;ignore_sticky_posts&#039; =&gt; 1, \/\/ otherwise the sticky posts show up undesired\n\t\t\t\t );\t\t\n\n\tif ( $slidertype &amp;&amp; $slidertype == &#039;random&#039; ) {\n\t\t$args = array_merge( $args, array( &#039;orderby&#039; =&gt; &#039;rand&#039; ) );\n\t}\n\tif ( $slidertype &amp;&amp; $slidertype == &#039;posts_pages&#039; ) {\n\t\t$post_ids = $graphene_settings[&#039;slider_specific_posts&#039;];\n\t\t$post_ids = preg_split(&quot;\/[\\s]*[,][\\s]*\/&quot;, $post_ids, -1, PREG_SPLIT_NO_EMPTY); \/\/ post_ids are comma separated, the query needs a array\n\t\t$post_ids = graphene_object_id( $post_ids );\n\t\t$args = array_merge( $args, array( &#039;post__in&#039; =&gt; $post_ids, &#039;posts_per_page&#039; =&gt; -1, &#039;orderby&#039; =&gt; &#039;post__in&#039; ) );\n\t}\n\tif ( $slidertype &amp;&amp; $slidertype == &#039;categories&#039; &amp;&amp; is_array( $graphene_settings[&#039;slider_specific_categories&#039;] ) ) {\n\t\t$cats = $graphene_settings[&#039;slider_specific_categories&#039;];\n\t\t$cats = graphene_object_id( $cats, &#039;category&#039; );\n\t\t$args = array_merge( $args, array( &#039;category__in&#039; =&gt; $cats ) );\n\n\t\tif ( $graphene_settings[&#039;slider_random_category_posts&#039;] )\n\t\t\t$args = array_merge( $args, array( &#039;orderby&#039; =&gt; &#039;rand&#039; ) );\n\t}\n\n\t\/* Get the posts *\/\n\t$sliderposts = new WP_Query( apply_filters( &#039;graphene_slider_args&#039;, $args ) );\n\treturn apply_filters( &#039;graphene_slider_posts&#039;, $sliderposts );\n}\n\nendif;\n\n\/**\n * Exclude posts that belong to the categories displayed in slider from the posts listing\n *\/\nfunction graphene_exclude_slider_categories( $request ){\n\tglobal $graphene_settings, $graphene_defaults;\n\n\tif ( $graphene_settings[&#039;slider_type&#039;] != &#039;categories&#039; ) return $request;\n\tif ( is_admin() ) return $request;\n\n\tif ( $graphene_settings[&#039;slider_exclude_categories&#039;] != $graphene_defaults[&#039;slider_exclude_categories&#039;] ){\n\t\t$dummy_query = new WP_Query();\n    \t$dummy_query-&gt;parse_query( $request );\n\n\t\tif ( get_option( &#039;show_on_front&#039; ) == &#039;page&#039; &amp;&amp; $dummy_query-&gt;query_vars[&#039;page_id&#039;] == get_option( &#039;page_on_front&#039; ) ) return $request;\n\n\t\tif ( ( $graphene_settings[&#039;slider_exclude_categories&#039;] == &#039;everywhere&#039; ) ||\n\t\t\t\t$graphene_settings[&#039;slider_exclude_categories&#039;] == &#039;homepage&#039; &amp;&amp; $dummy_query-&gt;is_home() )\n\t\t\t$request[&#039;category__not_in&#039;] =  graphene_object_id( $graphene_settings[&#039;slider_specific_categories&#039;], &#039;category&#039; );\n\t}\n\n\treturn $request;\n}\nadd_filter( &#039;request&#039;, &#039;graphene_exclude_slider_categories<\/code><\/pre>\n<p>Z g\u00f3ry bardzo dzi\u0119kuj\u0119 za pomoc:)<\/p>\n","protected":false},"template":"","class_list":["post-36165","topic","type-topic","status-closed","hentry","topic-tag-graphene","topic-tag-slider"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/36165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/36165\/revisions"}],"wp:attachment":[{"href":"https:\/\/pl.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=36165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}