Issue
I'm working on PHP to output the email content. I want to check the width size through on the style of the html tag that if the width size which is greater than 400, I want to change it to 306px.
Example:
style="width: 406px;
If the width value is greater than 300, I want to change it to:
style="width: 306px;
Have is the html content on my php page:
<div class="a3V ui-widget-content ui-resizable ui-resizable-resizing" style="width: 406px; height: 128px;"><div class="ui-resizable-handle ui-resizable-nw a3T" id="nw" style="left: -5px; top: -5px; cursor: nw-resize;"></div><div class="ui-resizable-handle ui-resizable-sw a3T" id="sw" style="left: -5px; bottom: -5px; cursor: sw-resize;"></div><div class="ui-resizable-handle ui-resizable-ne a3T" id="ne" style="right: -5px; top: -5px; cursor: ne-resize;"></div><div class="ui-resizable-handle ui-resizable-se a3T" id="se" style="right: -5px; bottom: -5px; cursor: se-resize;"></div><div class="ui-resizable-handle ui-resizable-n a3b" id="n" style="top: 0px; left: 0px; right: 0px; height: 1px; cursor: n-resize;"></div><div class="ui-resizable-handle ui-resizable-s a3b" id="s" style="bottom: 0px; left: 0px; right: 0px; height: 1px; cursor: s-resize;"></div><div class="ui-resizable-handle ui-resizable-w a3b" id="w" style="top: 0px; left: 0px; bottom: 0px; width: 1px; cursor: w-resize;"></div><div class="ui-resizable-handle ui-resizable-e a3b" id="e" style="top: 0px; right: 0px; bottom: 0px; width: 1px; cursor: e-resize;"></div><img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="Google" style="width: 406px;height: 128px;"></div>
Here is the code:
$mailbox= $link->prepare("SELECT * FROM Drafts WHERE id = ?");
$mailbox->execute([$id]);
if ($mailbox->rowCount() > 0) {
$row = $mailbox->fetch(PDO::FETCH_ASSOC);
$draft_id = $row['email_id'];
$draft_attached_files = $row['attached_files'];
$draft_message = $row['message'];
if (!empty($draft_message)) {
$draft_message = base64_decode($draft_message);
}
echo '<body>
<div id="mobile-app-container" data-reactroot="" style="height: 100%; overflow-y: auto;">
<div id="app" data-test-id="mobile-app" class="a6" tabindex="-1">
<div class="eM" role="message" style="display: block; overflow-y: auto;">
<div id="eMB" style="overflow-y: auto;">
<div class="mSG">';
echo $draft_message;
if (!empty($draft_attachments)) {
echo $draft_attachments;
}
echo '</div>
</div>
</div>
</div>
</div>';
echo "</html><body>";
I have got no idea how to check if the value is greater than 300, the only things I can think of would be like this:
if (strpos($draft_message, 'width:400px;') !== false) {
$draft_message = str_replace('width:400px;', 'width: 335px;', $draft_message);
}
I would have to write hundred of lines for each different value which is not the right way to do.
Can you please show me an example how I can check on the tag for the width size that if the width size is greater than 400, then I want to replace it with 306??
Thank you.
Solution
Perhaps add this somewhere:
<style>
div {
max-width: 306px !important;
}
</style>
Answered By - dqhendricks
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.