Opened 22 months ago
Last modified 12 months ago
#18297 new defect (bug)
Cropping in step 2 in Custom_Image_Header
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Media | Version: | 3.2.1 |
| Severity: | normal | Keywords: | dev-feedback needs-refresh |
| Cc: | travis@… |
Description
The cropping should not be based on the ratio but should follow some basic logic.
if ( ( yimg < HEADER_IMAGE_HEIGHT ) && ( ximg < HEADER_IMAGE_WIDTH ) ) no crop
else do follow current functionality
Attachments (1)
Change History (10)
So the PHP in function step_2 ():
Replace
if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) {
with
if ( ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) || ( ( $width < HEADER_IMAGE_WIDTH && $height < HEADER_IMAGE_HEIGHT ) ) ) {
And then in step_1():
Replace
<div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);">
with
<div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background:url(<?php esc_url ( header_image() ) ?>) top left no-repeat;">
- Cc travis@… added
- Component changed from General to Media
- Keywords has-patch added
comment:8
coffee2code — 13 months ago
- Keywords needs-refresh added; has-patch removed
- Version set to 3.2.1
Patch no longer applies cleanly against trunk (currently r20711).
When refreshing the patch, the diff used to produce the patch should be run from the root of the WP install and not a sub-directory.
comment:9
SergeyBiryukov — 12 months ago
Note: See
TracTickets for help on using
tickets.

So the JS could be:
if (yimg > yint) && (ximg > xinit) { if ( yimg < yinit || ximg < xinit ) { if ( ximg / yimg > ratio ) { yinit = yimg; xinit = yinit * ratio; } else { xinit = ximg; yinit = xinit / ratio; } } }