- This topic has 9 replies, 2 voices, and was last updated 3 years, 5 months ago by Tom.
March 4, 2017 at 11:47 pm #287224Chris
I’m using GP Premium – the Header plug-in.
I’m trying to find a way to set a focus point in the full width image so it scales to a sensible place (such as a face rather than random background) when viewing on mobile/tablet. At the moment it seems fairly arbitrary as to where it chooses to focus on.
I have found a plug-in called WP SMART CROP which works beautifully for images elsewher in the site e.g. Featured images – however, in the GP header images, GP seems to be overiding the functionality of this plug-in.
1. Is there a tried and tested way of doing this that I have yet to find in the forums?
2. If not – can you point me in the right direction of allowing WP SMARTCROP to provide the image cropping for the theme?
ChrisGeneratePress 1.3.44March 5, 2017 at 9:20 am #287406TomLead DeveloperLead Developer
Are you using the sizing options in Customize > Blog > Featured Images?
Cropping should be set to the center by default – I’ll have to look into it to see if we can allow a different area of focus in the cropping.March 5, 2017 at 10:14 am #287435Chris
Currently, i’my testing using the settings on a specific page/post. NI, the resize options are not set currently.
ChrisMarch 5, 2017 at 7:43 pm #287577TomLead DeveloperLead Developer
If you’re not using the resize options, the image shouldn’t be cropped/resized at all.
Any chance you can link me to the page in question?March 5, 2017 at 8:02 pm #287592Chris
This is the page with how I want the formatting to look give or take.
This is an example page where the header image is turned off and the plug-in WP Smart Crop handles the resizing of the feature image. As you can see, it keeps the image centered on a focus point I specified as it scales.
Selecting resize image ‘Enable’ or ‘Disable’ does not seem to effect behavior of image scaling?
ChrisMarch 5, 2017 at 10:49 pm #287612TomLead DeveloperLead Developer
Ah, you’re using the image as a background image, so it sets the full image as a background to the content you add.
Resizing images will only work on static images whether you use GP settings or that plugin I’m afraid.March 7, 2017 at 1:03 pm #288448Chris
So I found a solution to this using this piece of css which makes the background image focus perfectly when scaling for mobile etc.:
background-position: 50% 50%;
Now what I would like to do is put this into jQuery so that I can set the parameters of background-position dynamically. Apparently this piece of code should do the trick but it doesn’t seem to be working so I’m wondering if I’ve misunderstood how to add jQuery to GP.
At the moment, I’ve added the following to wp_header in Generate Hooks:
jQuery(‘generate-content-header’).css(‘background-position’, ‘50% 50%’);
Any ideas why it may not be working?
ChrisMarch 7, 2017 at 5:21 pm #288567TomLead DeveloperLead Developer
That jQuery is identical to writing the CSS as you have it now.
Either way, the jQuery would be:
jQuery( '.generate-content-header' ).css( 'background-position', '50% 50%' );March 7, 2017 at 5:32 pm #288576Chris
It was the . I was missing before generate-content-header. Working a charm now!
ChrisMarch 7, 2017 at 9:53 pm #288618
- You must be logged in to reply to this topic.