Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering function updates #206

Merged
merged 1 commit into from
Oct 6, 2015
Merged

Filtering function updates #206

merged 1 commit into from
Oct 6, 2015

Conversation

joemcgill
Copy link
Member

Now that we're no longer using a preg_replace_callback function in
tevkori_filter_content_images(), it doesn't make as much sense to use
the callback function the way we originally set it up. However, rather
that merging the two function, this turns the callback into a useful
utility function that accepts an img element and returns the HTML
including srcset and sizes attributes if we can.

Additionally, since we only add srcset and sizes when we're able to
parse the attachment id from the markup, we also no longer need to limit
our matches in the content filter by files containing the path to our
uploads folder. This resolves #190.


// Pass height and width to `tevkori_get_sizes_string()`.
/**
* Pass the 'height' and 'width' to 'wp_get_attachment_image_sizes()' to avoid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tevkori_get_sizes()'

@jaspermdegroot
Copy link
Member

The code looks good to me.

@bradt
Copy link

bradt commented Oct 5, 2015

Wow, this is a huge shift: no longer matching the src. Is there a conversation on Slack somewhere about this decision? I do think it's right, as querying attachments by image path is slow as hell compared to using IDs, but I'm just curious how the conversation went.

@joemcgill
Copy link
Member Author

Hi @bradt. We removed that custom query recently in order to speed up the display filter. Some of the relevant conversation can be found in the meeting logs from Sept. 25. Once we no longer needed the src it made sense to remove the code that was filtering images based on the path.

At some point, it would be nice to handle cases where we're not able to get the attachment_id by parsing the markup, at which point we will need to reconsider how we filter on image sources that contain a set of accepted paths.

@bradt
Copy link

bradt commented Oct 5, 2015

Awesome, great work pushing this forward! 😃

@joemcgill joemcgill force-pushed the filtering-function-updates branch from 740385b to 38f5f87 Compare October 6, 2015 01:09
Now that we're no longer using a `preg_replace_callback` function in
`tevkori_filter_content_images()`, it doesn't make as much sense to use
the callback function the way we originally set it up. However, rather
that merging the two function, this turns the callback into a useful
utility function that accepts an `img` element and returns the HTML
including `srcset` and `sizes` attributes if we can.

Additionally, since we only add `srcset` and `sizes` when we're able to
parse the attachment id from the markup, we also no longer need to limit
our matches in the content filter by files containing the path to our
uploads folder. This resolves #190.
@joemcgill joemcgill force-pushed the filtering-function-updates branch from 38f5f87 to c77b441 Compare October 6, 2015 01:10
@joemcgill
Copy link
Member Author

Fixed the inline docs as noted by @jaspermdegroot and rebased to a single commit so it can be merged cleanly.

joemcgill added a commit that referenced this pull request Oct 6, 2015
…dates

Refactor display filtering functions

Now that we're no longer using a preg_replace_callback function in
tevkori_filter_content_images(), it doesn't make as much sense to use
the callback function the way we originally set it up. However, rather
that merging the two function, this turns the callback into a useful
utility function that accepts an img element and returns the HTML
including srcset and sizes attributes if we can.

Additionally, since we only add srcset and sizes when we're able to
parse the attachment id from the markup, we also no longer need to limit
our matches in the content filter by files containing the path to our
uploads folder. This resolves #190.
@joemcgill joemcgill merged commit 3deda6c into dev Oct 6, 2015
@jaspermdegroot jaspermdegroot deleted the filtering-function-updates branch November 3, 2015 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider path filtering for images in content.
3 participants