- This topic has 3 replies, 2 voices, and was last updated 4 years, 2 months ago by Tom.
April 28, 2018 at 4:45 pm #562806AMBTL
Since srcset is generally a good thing, I suppose it would be a good idea to use it in page headers, especially because some wide images can be relatively heavy.
Unless I am missing something, it doesn’t work automatically in GP.
I have to use “Content” in Page Headers to merge them with navigation. And I don’t want to use backgrounds, because I want to preserve the aspect ratio.
When I add
<img src="/image-url" />, srcset is not generated (I kind of expected that :).
So, I came up with a workaround, but I’d say it’s not ideal and perhaps there is a better way. Here is what I did:
– create a dummy post, click on “ADD MEDIA” button and select the image in full-size
– save the post with the image and view it
– copy the img html using Inspector. It will include all srcset code and image urls
– paste it into the page header and adjust the width, otherwise it may not take the full-width of the screen
Simply copying the source text from the post edit screen won’t work, it won’t generate srcset.
Now, if we could have an Add Media button in Page Headers’ content tab, perhaps it would generate the srcset code automatically without any workarounds?
Or perhaps I am missing something and there is a better way?
One problem with this manual method may be modifying the image sizes at some point in the future and regenerating thumbnails (standard WordPress sizes and custom added sizes). Then the manually inserted URLs won’t work anymore.
TomGeneratePress 2.0.2GP Premium 1.6.2April 28, 2018 at 9:14 pm #562877TomLead DeveloperLead Developer
The Page Header content tab doesn’t use TinyMCE or the WP content filters, which is why srcset isn’t generated automatically.
While we could add the WP content filters to the content, it would likely cause more issues than it would solve.
While your method isn’t ideal, it’s probably the best way to go about it right now.
I’ll look into adding a similar Add Media button to Page Headers to make this easier.
Thanks!April 28, 2018 at 9:27 pm #562882AMBTL
OK, thanks Tom. Yeah, some kind of a media button would be very convenient, even regardless of the srcset thing.
CheersApril 29, 2018 at 9:17 am #563186
- You must be logged in to reply to this topic.