{"id":4203,"date":"2020-02-26T12:52:30","date_gmt":"2020-02-26T17:52:30","guid":{"rendered":"https:\/\/themespress.ca\/?p=4203"},"modified":"2021-11-18T06:40:26","modified_gmt":"2021-11-18T11:40:26","slug":"using-custom-sizes-on-images-with-acf-images","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/using-custom-sizes-on-images-with-acf-images\/","title":{"rendered":"Using Custom Sizes on Images with ACF Images"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>This tutorial will show you how to create a function that will allow you to display images with custom dimensions with <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_image_size\/\" target=\"_blank\" rel=\"noopener\">add_image_size<\/a>.<\/p>\n<p>Most importantly, we need to confirm that add_image_size is available in our functions as demonstrated below.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-9540120\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-9540120\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">add_action( &#039;after_setup_theme&#039;, &#039;siteweb_theme_setup&#039; );\nfunction siteweb_theme_setup() {\n\tadd_image_size( &#039;similaires&#039;, 460, 340, true );\n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Ensuite nous allons afficher notre sub field repeater ACF. Dans notre exemple de travail, il y a un sub field image ou on va lui donner l&#8217;argument de notre taille d&#8217;image personnalis\u00e9.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-9074403\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-9074403\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">&lt;?php \n\/\/\/ On appelle et on conditionne le field parent reapeater qui contient les sub field \nif(get_field(&#039;produits-similaire&#039;)) : while(the_repeater_field(&#039;produits-similaire&#039;)) : \n\/\/ On appelle le sub field image et on lui donne une url qui contient l&#039;argument d&#039;afficher notre taille personnalis&eacute;e.\n$image = get_sub_field(&#039;image-produits-similaires&#039;); \n$image_url = $image[&#039;sizes&#039;][&#039;similaires&#039;];\n?&gt;\n&lt;div class=&quot;eight columns nomargin prodimg&quot;&gt;\n&lt;a href=&quot;&lt;?php the_sub_field(&#039;lien-produits-similaire&#039;); ?&gt;&quot;&gt; \n&lt;img src=&quot;&lt;?php echo $image_url; ?&gt;&quot; alt=&quot;&lt;?php the_sub_field(&#039;titre-produits-similaire&#039;); ?&gt;&quot;&gt;\n&lt;h2 style=&quot;text-align:center&quot;&gt;&lt;?php the_sub_field(&#039;titre-produits-similaire&#039;); ?&gt;&lt;\/h2&gt;\n&lt;\/a&gt;\n&lt;\/div&gt;\n&lt;?php endwhile; endif; ?&gt;<\/pre><\/div><\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"This tutorial will show you how to create a function that will allow you to display images with custom dimensions with add_image_size. Most importantly, we need to confirm that add_image_size<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/using-custom-sizes-on-images-with-acf-images\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4937,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[],"class_list":["post-4203","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=4203"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4203\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4937"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}