Jump to content

PageImageSrcset


nbcommunication
 Share

Recommended Posts

Hello,

I've just released a new module called PageimageSource which effectively supersedes PageimageSrcset.

I've wanted to rewrite this module for a while now, to remove some features that I feel aren't necessary (e.g. UIkit widths / portrait mode), and have a more stripped back module that is more focused on specific functionality. I'd hoped to be able to do this by having a version 2.0.0, indicating breaking changes, but PW doesn't indicate this when upgrading, so the situation where users upgrade and things break would almost certainly happen.

I therefore decided to rewrite the module and release it under a different name. 

I don't expect to do any more work on PageimageSrcset, but will apply any fixes as required. If you are starting from scratch on a project, PageimageSource is the one to use.

If you are thinking to migrate a project using PageimageSrcset to PageimageSource, this list of changes should hopefully allow you determine if it is possible:

  • The sizes() method/property has been removed
  • The portrait mode has been removed (still possible through settings though - see the PageimageSource README for an example)
  • UIkit widths -> sizes has been removed
  • All the debug stuff has been removed
  • The render() method behaves differently. It is more geared toward a <picture> implementation (requested by @teppo)

Basically if all you've used is the default configuration and the srcset property, migration shouldn't cause any issues. Pretty much any other situation isn't suitable for migration.

Cheers,

Chris

  • Like 3
Link to comment
Share on other sites

  • 1 year later...

Hi @nbcommunication
I discovered the benefit of srcset tonight and it's easier with the module! Thanks.

I have a question. How can we manage "art direction" with the module? I had this 2 image sources but I don't know how to implement using module's API :

<picture>
	<source media="(max-width: 799px)" srcset="<?=page()->rootParent()->image_haut_mobile->url?>">
	<source media="(min-width: 800px)" srcset="<?=page()->rootParent()->image_haut->url?>">
	<img class="image" src="<?=page()->rootParent()->image_haut->url?>"  alt=''>
</picture>

Thanks!
Mel

Link to comment
Share on other sites

Hi @mel47,

This module isn't built to handle art direction I'm afraid, it is to provide a srcset property to a single Pageimage. Art direction will likely require more than one Pageimage (as your example suggests) so this would need to be handled with your own code.

However, the module should still be useful for your example; use ->srcset instead of ->url in the <source srcset> attribute.

Cheers,

Chris

Link to comment
Share on other sites

14 hours ago, nbcommunication said:

Hi @mel47,

This module isn't built to handle art direction I'm afraid, it is to provide a srcset property to a single Pageimage. Art direction will likely require more than one Pageimage (as your example suggests) so this would need to be handled with your own code.

However, the module should still be useful for your example; use ->srcset instead of ->url in the <source srcset> attribute.

Cheers,

Chris

Oh, yeah, I was thinking in term of <picture> not PageImage. But it works now by changing as suggested.
Thanks!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...