How to break this sprintf to different based on condition? i want to print credit and caption only if they are not empty

Question
$content .= sprintf(
                    '<div class="embedded cm photo c " style=" width:320px !important;" data-cid="%1$s">
                        <span class="galleryMask">
                            <img width="320" style="width:320px; height:180px;" src="%2$s" />
                            </span>
                        <span class="embeddedMediaCaption nested">
                            <div class="noExt">%3$s
                                <span style="display:block;margin:4px 0 0;line-height:1.25em;font-size:95%%">' . __( 'Photo credit:', 'nbc' ) . '%4$s</span>
                            </div>
                        </span>
                    </div>',
                    esc_attr( $image_noid ? $image_noid->get_object_id() : $unique_embed_integer++ ),
                    esc_url( $thumbnail_url ),
                    esc_html( $caption ),
                    esc_html( $credit )
                );
0
vowal 7 months 0 Answers 94 views 0

Leave an answer