Skip Navigation

[Resolved] Featured image cropping

This thread is resolved. Here is a description of the problem and solution.

Problem: I am using the wpv-post-featured-image shortcode with cropping applied, in a View of posts. However, some featured images are different heights. I want all the images the same size.

Solution: The "crop" feature only crops images, it does not stretch them to fill the dimensions you request. The original image must be at least as large as the crop dimensions, otherwise the image proportions will be incorrect when it is cropped.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-featured-image

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by bouchairY 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#757002

Hello
Please find here the design, i want to do using Views
hidden link

Please find here what I have get with views now
hidden link

Loop

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="1" pad="true">
		[wpv-item index=1]
		<div id="main-content" class="row">
		  <div class="dfd-content-wrap dfd-portfolio posts-standard layout-side-image content-bottom left-image isotope-columns-3">	
          <div class="col-sm-12">[wpv-post-body view_template="Loop item in Collections"]</div>
          </div>  
		</div>
		[wpv-item index=other]
            <div class="dfd-content-wrap dfd-portfolio posts-standard layout-side-image content-bottom left-image isotope-columns-3">
			<div class="col-sm-12">[wpv-post-body view_template="Loop item in Collections"]</div>
            </div>  
		[wpv-item index=pad]
			<div class="col-sm-12"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-12"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]Aucune colletion trouvée ![/wpml-string]</strong>
	[/wpv-no-items-found]
<!-- <nav class="navigation pagination" role="navigation">
  <div class="nav-links">[wpv-pager-nav-links]</div>
</nav> -->

[wpv-pagination][wpv-pager-nav-links output="bootstrap" first_last_links="true"][/wpv-pagination]
[wpv-layout-end]

and Loop item

<article class="portfolio type-portfolio status-publish has-post-thumbnail hentry dfd-portfolio text-left dfd-standard dfd-fade-out panr inited"><div class="cover"><div class="entry-thumb  dfd-img-lazy-load image-loaded">
	<span class="byline category">
		<a href=[wpv-post-taxonomy type="portfolio_category" format="url"] class="fn" style="background: #000000">
			<span class="cat-name">[wpv-post-taxonomy type="portfolio_category" format="name"]</span>
		</a>
	</span>
<span class="thumb-wrap">
<!-- <img src="<em><u>hidden link</u></em>" data-src="<em><u>hidden link</u></em>" width="1280" height="752" alt="Au pays des dragons" style="transform: matrix(1, 0, 0, 1, 0, 0);"> -->

[wpv-post-featured-image size='custom' width='1280' height='752' crop='true' crop_horizontal='center' crop_vertical='center' alt="[wpv-post-title]" attr=""]  
  
</span>
<a href="[wpv-post-url]" class="dfd-main-hover-link" title=""></a>
<div class="entry-hover"><span class="dfd-dots-link"><span class="dfd-left-dot"></span><span class="dfd-middle-dot">  
  
</span><span class="dfd-right-dot"></span></span><div class="dfd-hover-frame-deco hide"><div class="line line-top"></div><div class="line line-bottom"></div><div class="line line-left"></div><div class="line line-right"></div></div></div></div><div class="content-wrap"><h3 class="entry-title">[wpv-post-link]</h3><div class="entry-subtitle dfd-content-subtitle">
<span>[wpv-post-field name='stunnig_headers_subtitle']</span>
</div><div class="entry-content">
<p>[wpv-post-excerpt more="Lire la suite ..."]</p>
</div></div></div><div class="dfd-shadow-box hide"></div></article>

1. Images are not cropped and also don't have same height
2. On image, how to display only top portfolio category not all nested categories
3. Paginations design is not OK
4. in [wpv-post-excerpt more="Lire la suite ..."], read more is not displayed in the front

Thank you

#762894
Screen Shot 2018-04-29 at 1.29.37 PM.png

1. Images are not cropped and also don't have same height
The images are cropped as you specified. Take a look at the source of the page, and check the dimensions of these images:
hidden link.
It is cropped to be 752px tall.
hidden link
The original image is 768px tall.
So you can see that the image has been cropped using the 1280x752px dimensions you provided in the shortcode.

This theme has some CSS that stretches these images as needed to fill the horizontal space:

.dfd-content-wrap article.dfd-portfolio .entry-thumb img,.dfd-content-wrap article.dfd-gallery .entry-thumb img,.dfd-content-wrap article.dfd-portfolio_archive .entry-thumb img,.dfd-content-wrap article.dfd-gallery_archive .entry-thumb img,.dfd-portfolio-module article.dfd-portfolio .entry-thumb img,.dfd-portfolio-module article.dfd-gallery .entry-thumb img,.dfd-portfolio-module article.dfd-portfolio_archive .entry-thumb img,.dfd-portfolio-module article.dfd-gallery_archive .entry-thumb img,.dfd-gallery-module article.dfd-portfolio .entry-thumb img,.dfd-gallery-module article.dfd-gallery .entry-thumb img,.dfd-gallery-module article.dfd-portfolio_archive .entry-thumb img,.dfd-gallery-module article.dfd-gallery_archive .entry-thumb img {
    display: block;
    min-width: 100%;
}

That means that this vertical image gets stretched to fill the horizontal space in the gallery, resulting in an image that is taller than 752px. This is why your images have different heights. Try cropping the images at 768x452, which matches the proportions of the original image gallery.

2. On image, how to display only top portfolio category not all nested categories
Instead of the wpv-post-taxonomy shortcode, create a new View of the portfolio category taxonomy. Add a Query Filter "filter by term, set by the current post in the loop". Add another Query Filter "term parent", where term parent is "None" - this will result in only top-level terms. In the Loop Output editor, insert shortcodes like wpv-taxonomy-title or wpv-taxonomy-link to display information about each term. If you have additional questions about this, please create a separate ticket so we can discuss in more detail.

3. Paginations design is not OK
The pagination controls in the original example have a very specific markup and CSS structure. You may be able to copy + paste some of that into the Filter Editor of this View to recreate their design. If you need assistance with this, please create a separate ticket. Our policy is to address one issue per ticket, and this is a fairly complex problem to solve.

4. in [wpv-post-excerpt more="Lire la suite ..."], read more is not displayed in the front
One thing I can see is that your theme includes a CSS style that crops this section vertically at 6em. See the attached screenshot. This means that some text is cropped, but it's not controlled by the Types shortcode. You can try adding this CSS to override that style:

.page .dfd-content-wrap.left-image article.dfd-portfolio > .cover .entry-content {
    height: inherit;
}

Another thing I see is that your excerpt shortcode does not include a "length" or "count" attribute. You may need to specify these attributes like so:

[wpv-post-excerpt length="20" count="word" more="Lire la suite ..."]
#766617
label.jpg

Hello

Thank you for your reply

1.I added

[wpv-post-featured-image size='custom' width='768' height='452' crop='true' crop_horizontal='center' crop_vertical='center' alt="[wpv-post-title]" attr="class=test"]

where .test { transform: matrix(1, 0, 0, 1, 0, 0); }

to have the same situation as in the image

<img src="<em><u>hidden link</u></em>" data-src="<em><u>hidden link</u></em>" width="1280" height="752" alt="Au pays des dragons" style="transform: matrix(1, 0, 0, 1, 0, 0);">

but some images are taller than some ones

There is no way with views to have all images with the same height and width ?

2. You haven't understand me, I need to display the "root category" on the image label using

[wpv-post-taxonomy type="portfolio_category" format="name"]

3. I will open a new ticket

4. Fixed

Thank you

#770546

1. but some images are taller than some ones
Okay I see what you mean, let me ask my 2nd tier support team if it is possible to crop a portrait-mode image using landscape-mode dimensions. I'll update you shortly.

2. You haven't understand me, I need to display the "root category" on the image
Sorry let me explain more. It is not possible to achieve what you want with the wpv-post-taxonomy shortcode. There is no way to "filter" the term levels in this shortcode. It will always show all the post's terms from the term hierarchy, including nested terms. The best way to filter the applied terms and show only the root category is to use a View of the taxonomy, filtered by term parent, and also filtered by the current post in the loop, as I described before.

#770647

1. I see what's happening now, the original image is not large enough to fill the 768x452 dimensions. The original dimensions of this image are 512x768:
hidden link
The crop process will not upsize an image to fill the required dimensions, so the proportions of this image are off when it's cropped. The result is a 512x452 image, which is scaled differently than the other images.

So the best approach here is to use images that are at least 768px x 452px , in both dimensions. Otherwise the crop feature will produce images with undesirable proportions.

#771880

Thank you