hero12
Forum Replies Created
-
Forum: Plugins
In reply to: [NextGEN Facebook] og:image problempardon, thanks for your comments…
it’s easier than you can think… already explained.it’s enough to take the image size by getimagesize();
it’s pointless in the other way, ’cause on the post there may be external images without width/height tags and you can’t force users to always write width= and height= . If not, you ignore the images? No, THIS is wrong π
with getimagesize() you bypass any issue easily with a few lines of code.
the only issue COULD be a temporary connection problem, but that may be tolerated ’cause is really sporadic. Even in that case (and, if more images on the post content) you can always do a cycle to get the found and correct image in the cycle. The problem is if you steadily ignore the img without width height tags, instead.
thanksForum: Plugins
In reply to: [NextGEN Facebook] og:image problemwidth / height missing or too small for ngfb-opengraphyou have to avoid this, it’s pointless.
Please get the image size from that simple php function…
thanksForum: Plugins
In reply to: [NextGEN Facebook] og:image problempublic function get_size_info( $size_name = 'thumbnail' ) { if ( is_integer( $size_name ) ) return; if ( is_array( $size_name ) ) return; global $_wp_additional_image_sizes; if ( isset( $_wp_additional_image_sizes[$size_name]['width'] ) ) $width = intval( $_wp_additional_image_sizes[$size_name]['width'] ); else $width = get_option( $size_name.'_size_w' ); if ( isset( $_wp_additional_image_sizes[$size_name]['height'] ) ) $height = intval( $_wp_additional_image_sizes[$size_name]['height'] ); else $height = get_option( $size_name.'_size_h' ); if ( isset( $_wp_additional_image_sizes[$size_name]['crop'] ) ) $crop = $_wp_additional_image_sizes[$size_name]['crop']; else $crop = get_option( $size_name.'_crop' ); if ( ! is_array( $crop ) ) $crop = empty( $crop ) ? false : true; return array( 'width' => $width, 'height' => $height, 'crop' => $crop ); }and
// try and get the width and height from the image attributes if ( ! empty( $og_image['og:image'] ) ) { if ( preg_match( '/ width=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) ) $og_image['og:image:width'] = $match[1]; if ( preg_match( '/ height=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) ) $og_image['og:image:height'] = $match[1]; }this is unneeded stuff, really… recheck your code and simplify, this is my suggestion. The plugin, as it is now, fails with external images for sure…then i didn’t test deeply, maybe it works fine when you don’t use the preg_match…but the preg_match part must be reviewed… bye
Forum: Plugins
In reply to: [NextGEN Facebook] og:image problemATM your code finds
<img alt="something.jpg" src="http://www.example.com/images/something.jpg" width="510" height="307" />but doesn’t find something like
<img class="video_overlay" src="http://example.com/static/images/overlay/video_overlay.png"/><img class="video_image" src="http://images.example.com/thumbs/images/2015/06/25/38085-something.jpg" alt="something"/>that’s the only reason, it means that you search for width=”xxx” height=”xxx” in the html source. I’m reading your code, what do you mean as attachment or post thumbnail? You should remember that the user can insert into the post even external images on remote sites…and it’s not good if you don’t display them just for this reason.
you should use the getimagesize() or something like that, instead.
thanks for your attention
kind regardsForum: Plugins
In reply to: [NextGEN Facebook] og:image problemanother issue,
even if I set 2 images…the image at the bottom is not taken anyhow…
so it’s definitely a bugHow you get the width/height of the image?
If you search for the tags width height in html is wrong, you have to code in php something like getimagesize(“$url”); and then you have width in $size[0] and height in $size [1]Forum: Plugins
In reply to: [NextGEN Facebook] og:image problemunderstood the issue… you stop at the very first image and check if has the correct size. If not, you use the default image (if set by the user) Wrong. (’cause may be more images, sometimes the first image may be not so big, could be a little logo or such like that, could be a hidden image to display, a hidden image by jQuery… could be many things..)
EVEN IF the user chooses one image only, (“Max Images to Include”), You have to do a cycle until you find an image with the size greater than that set by the user.
eg. the user wants one image only and sets a 200×200 size (the minimum accepted on Facebook). You do an array searching for the images contained into the post until you find an image greater (or equal) than 200×200.
THEN, and only then, if the good image is not found, you insert the default image and so on…
hope this helps
Forum: Plugins
In reply to: [NextGEN Facebook] og:image problemHello, I think that there’s an issue if the image is at the bottom of the post content instead of the top… are you sure you tested it properly? Do You take any image, even if at the bottom and the top is text only? thanks
so, the errors are:
1) doesn’t find the correct image, but the last one only… you have to check your preg_match and array method… but didn’t you test it?
2) insert default image only when the found image is not big enough (must be >=200×200)
3) for the image size already wrote about it…bye
ok, no, it’s not a unique issue related to a3 Lazy Load ’cause I disabled it (and anyway, the img src are still there ’cause that plugin allows a noscript tag with the proper img src, so you can avoid conflict with that)
your code always skips the main images on a specific post…and finds the last image on the content
eg. code first image on the post content
<div id="attachment_47162" class="wp-caption aligncenter" style="width: 640px"><img class="wp-image-47162 size-large" src="http://example.com/wp-content/uploads/2015/06/BKlduBK-640x477.jpg" alt="BKlduBK" width="640" height="477"/> <p class="wp-caption-text"><em>Image via user goawaywhatsapp on Redditβs /r/DJs</em></p>instead it finds the very last image:
<img src="http://example.com/folder/google.png" title="Google+" class="ssba ssba-img" alt="Share on Google+"/>I tried with this
$output = preg_match_all( '/<img.+data-src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches );while the regex is correct, it doesn’t work anyway… maybe the conflict is the moment when a3 Lazy Load changes the url… otherwise I can’t understand, it should correctly match the url, even tested on regex101.com
can you try to install the a3 Lazy Load and test it? thanks
ok, understood π
there’s a conflict with the “a3 Lazy Load” plugin
’cause it adds
data-src=with the correct img url and the img src, instead, is something likedata:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7so i need to verify how to fix…or you can help about this
and… maybe an error somewhere on your code…
’cause on a post tested now, instead of the first image it takes a little google png from sharing bar at the very bottom… so it skipped many good images and you have to understand why…
you need to keep the first image on the post for sure OR you do a check to see if the image is big enough and according to this you insert the default image or not… I don’t think that’s good if you always insert the default image, before any other image…
hope this helps
at the moment with the current code…
echo '<meta property="og:image" content="' . esc_url( apply_filters( 'wpfbogp_image', $image ) ) . '"/>' . "\n"; $dimgurl = esc_url( apply_filters( 'wpfbogp_image', $image ) ); $size = getimagesize("$dimgurl"); echo '<meta property="og:image:width" content="' . $size[0] . '"/>' . "\n"; echo '<meta property="og:image:height" content="' . $size[1] . '"/>' . "\n";’cause you have width in $size[0] and height in $size[1]
π then if you want to do other checks is good for sure
so, you could do…
eg.
if ($post_image), get the width/height…
if $post_image size β₯200×200
insert… otherwise width/height of the default image.
Also, you could let the user choose to always use the default image (with its width/height) as an option. (not only to set…)
1) always use the default image? if yes, you just insert the default image and width/height
2) if not, you run that function and evaluate…
byehi π that’s required by Pre-caching… so you’re not forced to do a debugging. Tested ok, trust me…
obviously the image size must be β₯ 200×200have a nice day