Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Why not use wordpress markup for images? #66

Open
vralle opened this issue Nov 20, 2015 · 4 comments
Open

Why not use wordpress markup for images? #66

vralle opened this issue Nov 20, 2015 · 4 comments

Comments

@vralle
Copy link

vralle commented Nov 20, 2015

WordPress 4.4 will add native responsive image support by including srcset and sizes attributes to the image markup it generates: https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/

Example output by native WP Markup: https://gist.github.com/vralle/a74c5878d85fe222904d

@goldenapples
Copy link
Contributor

I definitely support making it easier to use the native responsive image markup generation.

I'm not entirely sure of the best way to do that. What if there was a filter around the $image_attrs array that the plugin markup builds; which could be used to add the sizes and srcset attributes; which you would use with functions like wp_get_attachment_image_sizes() and wp_get_attachment_image_srcset()?

@vralle
Copy link
Author

vralle commented Nov 22, 2015

This is the first step in the future. No one knows when and how the new features will be added.

We can add new filters to change the layout in the plugin. At the same time, the WP features already allow you to do the same. All this makes support more difficult, but it does not solve the issue of versatility.

The link above has added new examples.

there may be an example that can not be solved through a standard mechanism. At the moment, I do not understand what the problem solves the excessive number of filters and own markup by plugin

@vralle
Copy link
Author

vralle commented Nov 24, 2015

The example has been updated. Now the code has the maximum opportunity to customize the output:

  • Filter attributes shortcode
  • Filter attributes of the image
  • Filter attribute links
  • Filter output

The use of some attributes is filtered to prevent conflicts

For attachments output using the standard features of WP

Сlose to the balance between WP ecosystem and customization

@goldenapples
Copy link
Contributor

There are a lot of good ideas in the gist file you provided. Would you be willing to make a PR so that we can iterate through it?

I didn't realize at first that wp_get_attachment_image() was all that was needed to output the native responsive images. That's pretty cool. I certainly support using that function rather than building the image string by hand as we're doing.

I think the filters you have in place on the attributes for the image tag and the link tag are helpful, but I found it necessary to allow for filtering the entire output at several steps along the HTML generation process; thats what the weirdly named output filters img_shortcode_output_img_tag, img_shortcode_output_after_linkify, img_shortcode_output_after_captionify in the plugin are doing.

For example, one of the main use cases we have is appending a credit field immediately after the image or the the link around the image, but inside the caption markup. That wouldn't be trivial to do in the revised callback function as you've written it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants