Opened 8 years ago
Closed 6 years ago
#32137 closed enhancement (invalid)
Allow user-specified default image size when inserting image via Press This
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2 |
Component: | Press This | Keywords: | has-patch |
Focuses: | Cc: |
Description
Currently, when adding an image to a post in a Press This window, the image is inserted at full size by default. It would be helpful if the default insertion size could be specified by the user.
This is unrelated to Ticket #30269, as that concerns inserting images in the standard post editor.
Attachments (8)
Change History (14)
#1
@
8 years ago
- Keywords has-patch added
Patch attached, though there may be a more elegant way of accomplishing this.
#2
@
8 years ago
Curiously, even without my patches, if the user specifies a custom class name in the Press This window, the size-full
class name is overwritten (though alignnone
remains).
#4
@
8 years ago
32137.5.patch should work,but:
- please make sure to build your patches from the repository root: src/...
if ( $return === 'id' )
andif (get_option('image_default_size') != '' && get_option('image_default_size') != 'full')
should use Yoda conditions.$src_array[0]
should be checked to make sure it has the expected value before using it.preg_match( '/(class="[^"]+)"/',
should check for both " and ' as attribute delimiters.- might as well instantiate a variable for
get_option('image_default_size')
@
8 years ago
I think this may be a better approach for validating the output of wp_get_attachment_image_src
? I'm not positive.
@
8 years ago
FIX: I think this may be a better approach for validating the output of wp_get_attachment_image_src
? I'm not positive.
#5
@
8 years ago
Couple of notes:
- To do this properly (restrict the inserted image size) we will need to restrict it when first inserted, from JS. Otherwise the user will see the "full" image in Press This, and it will be replaced with the "default" size on saving. That difference can be pretty large, and definitely unexpected.
- The option
image_default_size
hasn't been used for years. As far as I remember it is a left over from the old media modal, pre 3.5. Perhaps we could useget_user_setting('imgsize')
which is the size the user selected when last inserting an image into the editor. However there's no way for the user to change that size in PT.
In that terms the current workflow seems better: insert the full image size (as found on the source site), and replace it with the same size on saving. If the user likes to change it, that can be done from the Edit Post screen in wp-admin, same as the rest of the more advanced settings.
Looking at 32137.7.patch, it seems like a good idea to return the attachment id from media_sideload_image()
, then do wp_get_attachment_image()
so the image tag has the proper class, etc. Then plugins will be able to use several of the image filters to change size or other attributes for the replacement image tag.
#6
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
With PT being moved into a plugin, moving the conversation to https://github.com/WordPress/press-this/issues/5
Patch to apply image_default_size setting to Press This insertions