Skip to content

Make GD compatible with WP Offload Media #2962

@nicolaslimet

Description

@nicolaslimet

Most GD images offloaded to the cloud provider don't show in Admin or frontend.

All post_images displayed by PHP can be fixed with a single hook (see below).
Custom image fields, like logo, or user-defined, aren't offloaded, so not an issue.

add_filter( 'geodir_get_image_tag', 'gdsnippet_kbh6cGFCv8tfvb_wp_offload_compat', 99, 1 );
function gdsnippet_kbh6cGFCv8tfvb_wp_offload_compat( $image_tag ) {
    return apply_filters( 'as3cf_filter_post_local_to_provider', $image_tag );
}

2 Issues remain (need more testing):

Default images:

With $image->post_id included in geodir_get_image_tag_class hook params, it'd be easy to add a wp-image-{attachment_ID} class.
Right now, can only be done with template override. Important because WP Offload Media can't use the URL (it rewrites it, and GD own 'assembly' messes the whole). It seems WP_UPLOAD_DIR is added twice. Adding the class solves the problem.

Image uploader input.

Post images don't show in front or back. Front can be fixed with template override, not admin.
Could be fixed both sides in one go, by making GeoDir_Media::get_field_edit_string() pluggable.

Seems that the URL change doesn't impact anything, editing title and/or caption still works, but would need more testing.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions