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

Add WP-CLI task to add srcset to all images #148

Closed
wants to merge 2 commits into from

Conversation

ryelle
Copy link

@ryelle ryelle commented Jul 24, 2015

First-pass PR for #143

Add wp respimg add-srcset, to check all posts (and pages, all public CPTs but attachments) for image tags and if the image does not already have a srcset attribute, add the srcset. This first saves a revision of the old post, makes the change, then updates the post with the srcset'd images.

I'm not sure DOMDocument is a great approach for replacing the image, so if something better is decided in #144, we can switch to that.

This is really beta, and could use a lot of testing/feedback.

ryelle added 2 commits July 23, 2015 16:06
Uses DOMDocument to find images, then pulls the image ID from the `wp-image-*` class (could switch to whatever content filtering is used for ResponsiveImagesCG#144, so we’re not reliant on something that might be disabled). Generate the srcset, add it to the image tag, and update the post.
@ryelle ryelle changed the title Add/wp cli add srcset Add WP-CLI task to add srcset Jul 24, 2015
@ryelle ryelle changed the title Add WP-CLI task to add srcset Add WP-CLI task to add srcset to all images Jul 24, 2015
@tevko
Copy link
Member

tevko commented Jul 24, 2015

@ryelle this looks awesome. What are the downsides to DOMDocument, if any?

@snrbrnjna
Copy link

+1 Why don't you merge this?

@joemcgill
Copy link
Member

Now that we've switched to using a display filter (#177) to add srcset and sizes on the front end instead of adding the attributes directly to the database, this is no longer needed. However, this might be a useful starting point for removing the attributes we used to add in earlier versions of the plugin. Closing for now.

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.

5 participants