• Resolved sublines

    (@sublines)


    Hi,

    thanks for making and maintaing this great plugin!

    I am not sure if this actually a problem caused by your plugin but maybe you can find out and point me in the right direction.

    I keep geeting this error:

    Uncaught ReferenceError: NAN is not defined

    in the console log, pointing me to a piece of code from this plugin.

    The code that seems to be causing the trouble looks like this:

    cwp_namespace.fluid_images.Widgets['category-posts-3'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,NAN);
    				cwp_namespace.fluid_images.widget = jQuery('#category-posts-2');
    cwp_namespace.fluid_images.Widgets['category-posts-2'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,NAN);
    				cwp_namespace.fluid_images.widget = jQuery('#category-posts-4');
    cwp_namespace.fluid_images.Widgets['category-posts-4'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,1);

    I think this comes from category-posts-widget/cat-posts.php

    What was causing it to output NaN?

    Thanks in advance!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter sublines

    (@sublines)

    Changing
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $number ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,<?php echo esc_attr( $ratio ); ?>);
    to
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $number ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,1);
    inside cat-posts.php works for me as a temporary hotfix but obviously this can’t be a permanent solution.
    Any ideas though why this line was causing a bug on my site?

    Plugin Author Mark-k

    (@mark-k)

    This is most likely an indication that the two widgets on which you get the error have a zero height, can you please check out what are the dimensions being used there?

    Plugin Author Daniel Floeter

    (@kometschuh)

    @sublines we are not very elegant here ;(

    The issue is fixed three weeks ago. We update the code on the www.remarpro.com SVG repository but we don’t increase the version number.

    Can you try to delete your widget and download it again with the new and fixed code from www.remarpro.com?
    Or you can download the cat-posts.php and override it manually at your web server: [your-Theme]\wp-content\plugins\category-posts\cat-posts.php

    This are the fixes, if you want to look at our fix:
    https://github.com/tiptoppress/category-posts-widget/commit/83c4cca319c63d5e44e0e4d6216801aadaa3949b

    https://github.com/tiptoppress/category-posts-widget/commit/72587826bb7d3bd37ba084692939cdf16ad1f032

    Thread Starter sublines

    (@sublines)

    Hi Mark and Daniel, thanks for the quick reply!

    @mark-k, I am not sure I understand what you mean. I haven’t set any height to the widgets and I also can’t find any setting for that. The settings of the widgets in question are set to only show the titles of the 5 most recent posts from a specified category – they don’t show the posts image, author, description or anything else.

    @kometschuh, I have replaced the cat-posts.php with the file you told me but I am still getting the same error in the console:

    Uncaught ReferenceError: NAN is not defined

    I can still apply the same temporary hotfix by changing the following line of code inside your file on line 2058 from
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $num ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,<?php echo esc_attr( $ratio ); ?>);
    to
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $num ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,1);

    Any ideas why

    <?php echo esc_attr( $ratio ); ?>

    causes the script to output “NAN”?

    Plugin Author Daniel Floeter

    (@kometschuh)

    Can you tell us a bit about how to place the widget:

    Where have you placed it. On a widget area, with an shortcode?

    How often do you have placed the widget?

    Can you write us your website url?

    Thread Starter sublines

    (@sublines)

    I have placed three category post widgets in the widget area and never used the shortcode.

    You can see the widgets live here.

    Scroll down past the content grid, the sidebar is located below the page instead of on the side. There you will find three widgets next to each other with the titles “Geschichten der Gegenwart”, “Jetzt aber!” and “Gespr?che”.
    Those are category post widgets, each set up to list the titles of the five most recent posts from their category.

    In the source code, you will see them as
    <aside id=”category-posts-3″ class=”widget cat-post-widget”></aside>,
    <aside id=”category-posts-2″ class=”widget cat-post-widget”></aside>
    and <aside id=”category-posts-4″ class=”widget cat-post-widget”></aside>

    Plugin Author Daniel Floeter

    (@kometschuh)

    But now you don’t use the code from GH at your site: https://github.com/tiptoppress/category-posts-widget/blob/master/cat-posts.php
    Please do not use the cat-posts.php file from www.remarpro.com SVG!

    I try a lot settings and try some placements without a feature image, but I can’t get an error as described above?

    Thread Starter sublines

    (@sublines)

    Hi Daniel,

    I am useing the code from GH at my site.
    I’ve copied the raw text from https://github.com/tiptoppress/category-posts-widget/blob/master/cat-posts.php and pasted it into the cat-posts.php in my plugin directory.

    The only change I have made is on line 2058 where I have replaced
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $num ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,<?php echo esc_attr( $ratio ); ?>);
    with
    cwp_namespace.fluid_images.Widgets['<?php echo esc_attr( $num ); ?>'] = new cwp_namespace.fluid_images.WidgetPosts(cwp_namespace.fluid_images.widget,1);
    because as I’ve said, if I dont replace

    <?php echo esc_attr( $ratio ); ?>

    inside the code, I still get the same

    Uncaught ReferenceError: NAN is not defined

    error, even with the new code from GH.

    Are there also other files from GH which I should download and use to replace with the files from the www.remarpro.com SVG?

    Plugin Author Daniel Floeter

    (@kometschuh)

    No. Only this file.

    Now we are interested in what cause the error.
    Another question, do you use and set feature images to your posts?

    Which PHP version do you use at your server?
    Which WordPress version do you use?
    Which Theme do you use?

    Thread Starter sublines

    (@sublines)

    Hi Daniel,

    we are using the fairly recent PHP version 7.0.27 and the most recent WordPress verison 4.9.4. We are using a custom theme based on this premium theme “paperback“.

    We use feature images for every post but the widget is set up to not show any images.
    I’ve tested that functionality of the custom post widget and it works fine, it shows the feature images as it should – I’m just not using it because it looks nicer without.

    I hope this helps!

    Plugin Author Daniel Floeter

    (@kometschuh)

    Can you try to use a thumbnail (thumb placeholder %thumb%) in the Template that you can select the thumbnail dimensions. Than set the thumbnail width and height to 150 and 150 and delete the %thumb% placeholder and store the widget instance?

    Thread Starter sublines

    (@sublines)

    Hi Daniel,

    that fixed it! Thanks for the great support.
    I remember trying thumbnails but I didn’t like them because they weren’t responsive.
    I had removed the numbers from height and width, hoping that they would cause the images to be 100% width instead. When that didn’t work, I removed the %thumb% placeholder entirely.

    Maybe you can make sure the widget defaults to 150 when no input was made or the input was removed.

    Plugin Author Daniel Floeter

    (@kometschuh)

    What do you mean with not responsive images? Do you mean fluid images?

    It is possible your Theme CSS cause a fix width.

    You can try the images again with the new code. We give a strong focus to support responsive layouts: https://tiptoppress.com/countless-types-uses-responsive-layouts/

    Anyway we want refactor some code lines for older settings which comes from updated widget instances.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Uncaught ReferenceError’ is closed to new replies.