Skip to content

Conversation

@RabbiIslamRony
Copy link
Member

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

How to reproduce the issue or how to test the changes:

  1. Add a video or audio element inside a listing description where the media URL is placed inside an <a> tag instead of the src attribute.
  2. View the listing on the frontend.
  3. Confirm that the video/audio does not play due to an empty src attribute.
  4. Apply this patch and reload the listing view page.
  5. Verify that the media files now load and play correctly.

Before & After

Before:
Video/audio tags rendered with empty src, media URL inside <a> link
https://prnt.sc/U3qAFNqyGsT-

After:
Media URL correctly extracted and applied to src, video/audio plays properly
https://prnt.sc/TnUnKQpcHMwD


Linked Issues

Fixes # (please add issue number)
#1366


Details

Fix: Extract src URLs from links in video/audio tags for proper media playback

Problem

  • Video and audio tags were rendered with empty src attributes.
  • Actual media URLs were incorrectly placed inside nested <a> tags.
  • Media players failed to load because the src attribute was missing.

Solution

Implemented fix_media_src_attributes() method that:

  • Detects <video> and <audio> tags missing valid src attributes
  • Extracts media URLs from links inside the tag
  • Assigns the extracted URL to the src attribute
  • Removes the now-unnecessary <a> tag nested inside

This ensures WordPress mediaelement.js can properly initialize the media player.


Files Changed

  • includes/model/SingleListing.php — Added fix_media_src_attributes() helper method

Testing

  • ✅ Video files now load and play correctly on listing view pages
  • ✅ Audio files now load and play correctly
  • ✅ Media players initialize successfully with correct source URLs

Checklist

- Fix media embeds processing in get_contents() method
- Extract src URLs from links inside video/audio tags
- Enqueue WordPress mediaelement scripts for proper player initialization
- Enable media buttons in listing description editor
- Add media plugin to TinyMCE configuration

Fixes issue where video and audio files added to listing descriptions
were not playing on the frontend. Media elements now properly load
and play with full controls support.
- Reuse filter_single_listing_content method to avoid code duplication
- Extract media src fix into separate helper method for better maintainability
- Reduce code from 50+ lines to 8 lines in get_contents method
- Improve code organization and readability
@RabbiIslamRony RabbiIslamRony self-assigned this Nov 18, 2025
@RabbiIslamRony RabbiIslamRony added this to the v8.5.3 milestone Nov 18, 2025
@Armanul46 Armanul46 modified the milestones: v8.5.3, v8.5.4 Dec 1, 2025
@iamibrahimriaz
Copy link
Collaborator

Looks Good

@Armanul46 Armanul46 merged commit 53a9605 into sovware:development Dec 11, 2025
1 check passed
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.

3 participants