BP_REST_Activity_Endpoint::bp_rest_activity_remove_lazyload( string $content, BP_Activity_Activity $activity )

Removed lazyload from link preview embed.

Description

Parameters

$content

(Required) Activity Content.

$activity

(Required) Activity object.

Return

(null|string|string[])

Source

File: bp-activity/classes/class-bp-rest-activity-endpoint.php

2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
public function bp_rest_activity_remove_lazyload( $content, $activity ) {
    $link_embed = bp_activity_get_meta( $activity->id, '_link_embed', true );
 
    if ( empty( $link_embed ) ) {
        return $content;
    }
 
    $content = preg_replace( '/iframe(.*?)data-lazy-type="iframe"/is', 'iframe$1', $content );
    $content = preg_replace( '/iframe(.*?)class="lazy/is', 'iframe$1class="', $content );
    $content = preg_replace( '/iframe(.*?)data-src=/is', 'iframe$1src=', $content );
 
    return $content;
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.