Skip to content

13108-Preview-for-the-social-sharing-buttons #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions view/frontend/templates/addthis-js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
?>
<?php
/**
* @var $block \Magefan\Blog\Block\Social\AddThi
* @var $block \Magefan\Blog\Block\Social\AddThis
* @var $mfSecureRenderer \Magefan\Community\Api\SecureHtmlRendererInterface
*/
?>
<?php $script = "
function mfShareWindowOpen(url, type) {
function mfShareWindowOpen(url, type, image) {
function reverse(s){
return s.split('').reverse().join('');
}
Expand All @@ -24,7 +24,7 @@
u = reverse('" . strrev('https://www.facebook.com/sharer/sharer.php?u=') . "') + url;
break;
case 'pinterest':
u = reverse('" . strrev('https://pinterest.com/pin/create/button/?url=') . "') + url;
u = reverse('" . strrev('https://pinterest.com/pin/create/button/?url=') . "') + url + '&media='+ image;
break;
case 'twitter':
u =reverse('" . strrev('http://twitter.com/share?url=') . "') + url;
Expand Down
1 change: 1 addition & 0 deletions view/frontend/templates/post/list-modern.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
<?php if ($featuredImage) { ?>
<?php
$featuredImage = $imageHelper->init($featuredImage)->resize($width, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
$featuredImgAlt = $_post->getData('featured_list_img_alt') ?: $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
Expand Down
11 changes: 9 additions & 2 deletions view/frontend/templates/post/list/item.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<?php
$_post = $block->getPost();
$_postUrl = $block->escapeUrl($_post->getPostUrl());
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle());

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: 722;
?>
<li class="post-holder post-holder-<?= (int)$_post->getId() ?>">
<div class="post-header">
Expand All @@ -34,7 +38,7 @@ $_postName = $block->escapeHtml($_post->getTitle());
<div class="post-sharing post-sharing-top old-post-list-item">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
Expand All @@ -55,6 +59,8 @@ $_postName = $block->escapeHtml($_post->getTitle());
<?php $featuredImage = $_post->getFeaturedListImage() ?: $_post->getFeaturedImage(); ?>
<?php if ($featuredImage) { ?>
<?php
$featuredImage = $imageHelper->init($featuredImage)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
$featuredImgAlt = $_post->getData('featured_list_img_alt') ?: $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
Expand All @@ -63,7 +69,8 @@ $_postName = $block->escapeHtml($_post->getTitle());
<div class="post-ftimg-hld">
<a href="<?= /*@noEscape*/ $_postUrl ?>"
title="<?= /*@noEscape*/ $_postName ?>">
<img src="<?= $block->escapeUrl($featuredImage) ?>"
<img src="<?= $block->escapeUrl($featuredImage) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
</a>
</div>
Expand Down
65 changes: 36 additions & 29 deletions view/frontend/templates/post/view-modern.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
*/
?>
<?php
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postName = $block->escapeHtml($_post->getTitle(), null);
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle(), null);

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: 722;
?>
<?= $block->getStyleViewModel()->getStyle('Magefan_Blog::css/bootstrap-4.4.1-custom-min.css') ?>
<div class="_post-view post-view-modern">
Expand All @@ -27,13 +31,13 @@
<!-- post category-->
<?php if ($_categoriesCount = $_post->getCategoriesCount()) { ?>
<div class="post-category mb-4">
<?php foreach ($_post->getParentCategories() as $ct) { ?>
<a class="category-name" href="<?= $block->escapeUrl($ct->getCategoryUrl()) ?>"
title="<?= $block->escapeHtml($ct->getTitle()) ?>">
<?= $block->escapeHtml($ct->getTitle()) ?>
</a>
<?php } ?>
</div>
<?php foreach ($_post->getParentCategories() as $ct) { ?>
<a class="category-name" href="<?= $block->escapeUrl($ct->getCategoryUrl()) ?>"
title="<?= $block->escapeHtml($ct->getTitle()) ?>">
<?= $block->escapeHtml($ct->getTitle()) ?>
</a>
<?php } ?>
</div>
<?php } ?>

<!-- block data -->
Expand All @@ -51,8 +55,8 @@
<?php } ?>

<?php
$coAuthors = $_post->getRelatedCoauthors();
$coAuthorsCount = count($coAuthors);
$coAuthors = $_post->getRelatedCoauthors();
$coAuthorsCount = count($coAuthors);
?>
<?php if ($coAuthorsCount) { ?>
<?= $block->escapeHtml(__('and')) ?>
Expand Down Expand Up @@ -108,13 +112,16 @@
<!-- Post Image -->
<?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
<?php
$featuredImgAlt = $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
$featuredImage = $imageHelper->init($featuredImage)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
$featuredImgAlt = $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
?>
<div class="post-featured-image">
<img src="<?= $block->escapeUrl($featuredImage) ?>"
<img src="<?= $block->escapeUrl($featuredImage) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
</div>
<?php } ?>
Expand Down Expand Up @@ -146,20 +153,20 @@
<div class="post-bottom">

<?php if ($block->displayAddThisToolbox()) : ?>
<!-- Post Sharing -->
<div class="post-sharing post-sharing-bottom">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<!-- Post Sharing -->
<div class="post-sharing post-sharing-bottom">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
<div class="label"><?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?></div>
</div>
<div class="label"><?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?></div>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
<!-- END Post Sharing -->
<!-- END Post Sharing -->
<?php endif; ?>

<?= $block->getChildHtml('blog.post.bottom') ?>
Expand Down
11 changes: 9 additions & 2 deletions view/frontend/templates/post/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<?php
$_post = $block->getPost();
$_postUrl = $_post->getPostUrl();
$_postImage = $_post->getOgImage()? $_post->getOgImage() : $_post->getFeaturedImage();
$_postName = $block->escapeHtml($_post->getTitle(), null);

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: 722;
?>
<div class="post-view">
<div class="post-holder post-holder-<?= (int)$_post->getId() ?>">
Expand All @@ -28,7 +32,7 @@ $_postName = $block->escapeHtml($_post->getTitle(), null);
<div class="post-sharing post-sharing-top old-post-view">
<div class="share-elements">
<?php foreach ($block->getAllowedSocialNetworks() as $network) { ?>
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>')">
<div class="icon-wrapper icon-<?= strtolower($network) ?>" onclick="mfShareWindowOpen('<?= $block->escapeUrl($_postUrl) ?>', '<?= strtolower($network) ?>', '<?= $_postImage ?>')">
<div class="icon" title="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
<img src="<?= $this->getViewFileUrl('Magefan_Blog::images/social/' . strtolower($network) . '.svg') ?>" alt="<?= $block->escapeHtml(__('Share on %1', $network == 'Twitter' ? "X" : $network)) ?>">
</div>
Expand All @@ -46,13 +50,16 @@ $_postName = $block->escapeHtml($_post->getTitle(), null);
<div class="post-description clearfix">
<?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
<?php
$featuredImage = $imageHelper->init($featuredImage)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
$featuredImgAlt = $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
?>
<div class="post-ftimg-hld">
<img src="<?= $block->escapeUrl($featuredImage) ?>"
<img src="<?= $block->escapeUrl($featuredImage) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
</div>
<?php } ?>
Expand Down
12 changes: 11 additions & 1 deletion view/frontend/templates/post/view/comments/magefan.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
$session = $block->getCustomerSession();

$canPost = $block->canPost();

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: '';
?>
<div id="post-comments">
<div class="c-count">
Expand All @@ -27,8 +30,15 @@
<!-- reply form -->
<div class="c-reply cf">
<?php if ($image = $block->getCustomerImage()) { ?>
<?php
$image = $imageHelper->init($image)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
?>

<div class="c-img">
<img src="<?= $block->escapeUrl($image) ?>" alt="<?= $block->escapeHtml($block->getCustomerName()) ?>">
<img src="<?= $block->escapeUrl($image) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($block->getCustomerName()) ?>">
</div>
<?php } ?>
<div class="c-replyform <?php if ($canPost) { echo 'no-active'; } ?>">
Expand Down
11 changes: 10 additions & 1 deletion view/frontend/templates/post/view/comments/magefan/comment.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
<?php
$comment = $block->getComment();
$numberOfCommentsToDisplay = $block->getNumberOfReplies();

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: 772;
?>
<div class="c-comment c-comment-parent-<?= (int)$comment->getParentId() ?>"
<?php if ($comment->getIsHidden()) { echo 'style="display:none"'; } ?>>
<?php if ($authorImage = $comment->getAuthorImage()) { ?>
<?php
$authorImage = $imageHelper->init($authorImage)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
?>
<div class="c-img">
<img src="<?= $block->escapeUrl($authorImage) ?>" alt="<?= $block->escapeHtml($comment->getAuthorName()) ?>">
<img src="<?= $block->escapeUrl($authorImage) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($comment->getAuthorName()) ?>">
</div>
<?php } ?>
<div class="c-post c-post-<?= (int)$comment->getId() ?>" id="c-post-<?= (int)$comment->getId() ?>">
Expand Down
2 changes: 2 additions & 0 deletions view/frontend/templates/sidebar/recent.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
<?php
if ($featuredImage) {
$featuredImageUrl = $imageHelper->init($_post->getFeaturedListImg() ?: $_post->getFeaturedImg())->resize($width, $height);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
} else {
$featuredImageUrl = $this->getViewFileUrl('Magefan_Blog::images/default-no-image.png');
}
?>
<img data-width-amp="<?= $width ?>" data-height-amp="<?= $height ?>" layout="responsive" src="<?= $block->escapeUrl($featuredImageUrl) ?>"
<?php if ($widthAndHeight) echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<?php
$_postCollection = $block->getPostCollection();
$id = rand(10000, 20000);

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: '';
?>
<?php if ($_postCollection->count()) { ?>

Expand Down Expand Up @@ -49,7 +52,13 @@
<div class="col-sm-5">
<div class="post-image">
<?php if ($post_image = $_post->getFeaturedImage()) { ?>
<img src="<?= $block->escapeUrl($post_image); ?>" alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
<?php
$post_image = $imageHelper->init($post_image)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();
?>
<img src="<?= $block->escapeUrl($post_image); ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
<?php } ?>
<div class="post-date">
<span class="day"><?= $block->escapeHtml(date("j", strtotime((string)$postDate))); ?></span>
Expand Down
10 changes: 9 additions & 1 deletion view/frontend/templates/widget/porto_theme_recent_home.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

<?php
$_postCollection = $block->getPostCollection();

$imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
$imageWidth = (int)$block->getFeaturedImageWidth() ?: '';
?>
<?php if ($_postCollection->count()) { ?>
<h2 style="margin:0 0 18px 0;font-size:18px;font-weight:600;text-align:center" class="theme-color a-center"><?= $block->escapeHtml($block->getTitle()) ?></h2>
Expand All @@ -34,12 +37,17 @@
<?php $featuredImage = $_post->getFeaturedListImage() ?: $_post->getFeaturedImage(); ?>
<?php if ($featuredImage) { ?>
<?php
$featuredImage = $imageHelper->init($featuredImage)->resize($imageWidth, null, false);
$widthAndHeight = $imageHelper->getWidthAndHeigth();

$featuredImgAlt = $_post->getData('featured_list_img_alt') ?: $_post->getData('featured_img_alt');
if (!$featuredImgAlt) {
$featuredImgAlt = $_postName;
}
?>
<img src="<?= $block->escapeHtml($featuredImage) ?>" alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
<img src="<?= $block->escapeHtml($featuredImage) ?>" <?php if ($widthAndHeight)
echo ' width="' . $widthAndHeight['width'] . '" height="' . $widthAndHeight['height'] . '" ' ?>
alt="<?= $block->escapeHtml($featuredImgAlt) ?>" />
<?php } ?>
</div>
</div>
Expand Down
Loading