Skip Navigation

[Resolved] Thumbnail size attribute not working with Types image field

This thread is resolved. Here is a description of the problem and solution.

Problem:
The Types shortcode for image field does not work after after migrating website

Solution:
The issue seems to be related to migrating the database between local, I suggest you try to update your database after migrating website, see our document:
How do I migrate a WordPress site from one domain to the other?
https://toolset.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

Relevant Documentation:
https://toolset.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

This support ticket is created 8 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 11 replies, has 3 voices.

Last updated by margaritR 8 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#357923

I'm using Slick Carousel (hidden link) with Types and Views. I've done this on many sites and it works well. My problem is that image thumbnail sizes are not being displayed in the slider or the slider controls, despite using the size="thumbnail" or size="large" attribute within the Types shortcode.

You can see the issue on the site here: hidden link

Below is html for the carousel content template shown on that page. The larger image in the carousel should be loading a "large" size thumbnail, and the carousel control images should be loading "thumbnail" size images. Both places in the carousel are loading the full image. This used to work, but an update at some point must have broken it.

I also get the following php error error when debug is enabled:

Notice: Trying to get property of non-object in C:\Users\esaner\Documents\Sites\superiorbuildings.dev\content\plugins\types\embedded\views\image.php on line 815

Content Template Code:

<div class="three-fifths first slider">
  <div class="building-slider">
    [wpv-for-each field="wpcf-building-photos"]
    	<div>
        	<a href="[types field="building-photos" size="full" url="true"][/types]" rel="full-size"><img data-lazy="[types field="building-photos" size="large" url="true"][/types]" /></a>
	</div>
	[/wpv-for-each]
  </div>
  <div class="building-slider-nav">
      <div>
          [types field="building-photos" size="thumbnail" align="none" separator="</div><div>"][/types]
      </div>
  </div>
</div>
<div class="two-fifths description">
  [wpv-post-body view_template="None"]
</div>
#357924

The php error was copied from my local dev site, but it also appears on the production site if debug is enabled there.

#357957

Dear eSaner,

I can not duplicate same problem, see below test site:
hidden link
user/pass: xgren/111111

Using same codes and images as you mentioned above.

I checked the source codes of Views plugin file \plugins\types\embedded\views\image.php on line 815:
$data = $message->error_data;

This should be a PHP error, could you try this:
1) deactivate other plugin and switch to wordpress default theme, and test again
2) Enable the PHP debug mode, copy/paste the debug logs here:
PHP Debugging
In case you think that Types or Views are doing something wrong (what we call a bug), you should enable PHP error logging. Again, edit your wp-config.php file and add the following:

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
This will produce a file called ‘error_log.txt’ in your WordPress root directory. Make sure that the web server can create and write this file. If it cannot, use an FTP program to create the file and make it writable to Apache (normally, user www-data).
https://toolset.com/documentation/user-guides/debugging-types-and-views/

#359788
homepage-thumbnails.jpg

This is still a problem, and it's now occurring on another site as well. The PHP Debug logs just list the same error: Trying to get property of non-object in C:\Users\esaner\Documents\Sites\superiorbuildings.dev\content\plugins\types\embedded\views\image.php on line 815.

I've narrowed things down a bit:

1. Deactivating all plugins except Types and Views and switching to default Twenty Sixteen theme does not fix the issue.

2. Same as you, I cannot replicate the issue on fresh installs of either WordPress 4.3.1 or WordPress 4.4.1.

3. The issue seems to be related to migrating the database between local, staging, and production environments. This problem is now also occurring on the site hidden link. The production site hidden link is fine and runs on WP 3.8.1. I migrated the production database to a local version of the site running on DesktopServer. I updated all plugin and WP core files. Then I noticed images on the homepage were not loading as thumbnails. I pushed all file updates to the staging site and it still worked fine. I migrated the database to the staging site and now it is has the same problem.

Attached is a screenshot showing the images on the homepage of the staging site that are not loading as thumbnails.

Can I privately send you access to the staging site? I'm not sure how to fix this.

Thank you for your help.

#359798

Here's the call stack that appears below the error on the homepage of the local version of the friedenswald site:

Call Stack
# Time Memory Function Location
1 0.0019 190152 {main}( ) ..\index.php:0
2 0.0023 192192 require( 'C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-blog-header.php' ) ..\index.php:4
3 1.0681 48197280 require_once( 'C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\template-loader.php' ) ..\wp-blog-header.php:16
4 1.0849 48434872 include( 'C:\Users\esaner\Documents\Sites\friedenswald.dev\content\themes\genesis\page.php' ) ..\template-loader.php:89
5 1.0849 48434928 genesis( ) ..\page.php:15
6 1.7020 50232304 do_action( ) ..\framework.php:40
7 1.7020 50233208 call_user_func_array:{C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\plugin.php:525} ( ) ..\plugin.php:525
8 1.7020 50233288 genesis_do_loop( ) ..\plugin.php:525
9 1.7021 50233376 genesis_standard_loop( ) ..\loops.php:46
10 1.7078 50242848 do_action( ) ..\loops.php:98
11 1.7079 50243776 call_user_func_array:{C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\plugin.php:525} ( ) ..\plugin.php:525
12 1.7079 50243888 genesis_do_post_content( ) ..\plugin.php:525
13 1.7079 50243912 the_content( ) ..\post.php:348
14 1.7079 50244584 apply_filters( ) ..\post-template.php:230
15 1.7112 50249072 call_user_func_array:{C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\plugin.php:235} ( ) ..\plugin.php:235
16 1.7112 50249088 do_shortcode( ) ..\plugin.php:235
17 1.7115 50252624 preg_replace_callback ( ) ..\shortcodes.php:223
18 1.7115 50254824 do_shortcode_tag( ) ..\shortcodes.php:223
19 1.7115 50255200 call_user_func:{C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\shortcodes.php:326} ( ) ..\shortcodes.php:326
20 1.7115 50255224 WP_Views->short_tag_wpv_view( ) ..\shortcodes.php:326
21 1.7149 50257056 WP_Views->render_view_ex( ) ..\wpv.class.php:556
22 1.7150 50259064 WP_Views->render_view( ) ..\wpv.class.php:1503
23 1.7263 50312408 wpv_do_shortcode( ) ..\wpv.class.php:1739
24 1.7943 51303544 do_shortcode( ) ..\wpv-shortcodes.php:4000
25 1.7946 51307272 preg_replace_callback ( ) ..\shortcodes.php:223
26 1.7946 51310672 do_shortcode_tag( ) ..\shortcodes.php:223
27 1.7947 51311264 call_user_func:{C:\Users\esaner\Documents\Sites\friedenswald.dev\wp\wp-includes\shortcodes.php:326} ( ) ..\shortcodes.php:326
28 1.7947 51311288 wpcf_shortcode( ) ..\shortcodes.php:326
29 1.7947 51312224 types_render_field( ) ..\frontend.php:66
30 1.7969 51315320 types_render_field_single( ) ..\frontend.php:191
31 1.7970 51317832 call_user_func:{C:\Users\esaner\Documents\Sites\friedenswald.dev\content\plugins\types\embedded\frontend.php:284} ( ) ..\frontend.php:284
32 1.7970 51317848 wpcf_fields_image_view( ) ..\frontend.php:284
33 1.7975 51319120 types_image_resize( ) ..\image.php:388
34 1.7977 51319896 Types_Image_View->resize( ) ..\image.php:23
35 1.7978 51321328 Types_Image_View::__resizeImg( ) ..\image.php:102
36 1.7978 51321480 Types_Image_Utils::checkEditRequirements( ) ..\image.php:125
37 1.7980 51322496 Types_Error->addError( ) ..\image.php:365

#360032

I suggest you try to update your database after migrating website, see our document:
How do I migrate a WordPress site from one domain to the other?
https://toolset.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/

#360035
view.jpg
homepage-frontend.jpg
homepage-admin.jpg
custom-field.jpg
content-template.jpg

I use WP Migrate DB Pro to migrate the database, which does all the things mentioned in that article.

So now I have this custom field, view, and content template setup correctly, but the image is still loading full size, instead of thumbnail size. This happens even with all other plugins deactivated and the theme switched to twenty sixteen.

I have attached screenshots of the custom field setup, view, content template, homepage admin edit screen, and homepage front end screen with inspector showing the image is not loading correctly. How can we fix this?

#360083

As you mentioned above:
The issue seems to be related to migrating the database
Please check this:
Does it works in your original website?
If it works, I do not have copy of plugin "WP Migrate DB Pro" in my localhost, and do not familiar with this plugin, then please check this problem with the author of plugin "WP Migrate DB Pro" for it.
Or you can contact our certified partners for it:
https://toolset.com/consultant/

#360246

I am disappointed that you are unable to provide more assistance for this problem. I have encountered this issue on two separate sites now, done some work to troubleshoot this issue, have provided several screenshots showing how things are setup, but I don't feel like I'm getting very good support in return.

I understand that you don't have a copy of WP Migrate DB Pro, but Types/Views and WP Migrate DB Pro are both very popular, well written premium plugins. If there is a conflict between these plugins, it is something you should be interested in identifying, even if the solution to fixing the problem lies with the developers of WP MIgrate DB Pro.

In addition, the php error I'm getting on the homepage references a Types plugin file: images.php. If I go to WP Migrate DB Pro and ask for assistance, they are going to look at that error and say the problem is with Types/Views.

I've gotten good support from Types/Views in the past and hope that can continue. Please reconsider your willingness to help resolve this.

Thanks.

#360369

Sorry, as you can see in post:
https://toolset.com/forums/topic/thumbnail-size-attribute-not-working-with-types-image-field/#post-357957
I can not duplicate same problem, it works fine in the test site.

As you mentioned above, it is a problem related to plugin "WP Migrate DB Pro", but I do not have a copy of it in my localhost, if you still needs assistance for it, please provide a downloadable URL for the plugin "WP Migrate DB Pro", and describe detail steps to duplicate same problem, I need test and debug it in my localhost, thanks

#361588

Louy, I have narrowed down the problem and have instructions for you to duplicate it. I believe the problem is related to how image fields use the guid field to calculate the attachment ID.

1. Create a new site (we'll call it Site 1) with a fresh install of WP 4.4.1, Twenty Sixteen theme, Types, WP-Views, and WP Migrate DB (the free version: https://wordpress.org/plugins/wp-migrate-db/)

2. Use Types to create a repeating image field for the Pages post type.

3. Create a view that displays the repeating image field and outputs the "Thumbnail" size. Allow the view to include the current page in the query results, and filter the view by Post ID. Enter the post ID for a page (create a page first, if none exists).

4. Edit the page that you chose to filter the view by. Add multiple images to the image field. Insert the view into the page. Look at the page on the frontend: the images should display correctly ("thumbnail" size).

5. Create another new site (we'll call it Site 2) the same WP version, theme and plugins as Site 1.

6. Copy the contents /wp-content/uploads directory from Site 1 and use it to replace the uploads directory in Site 2.

7. In Site 1, Go to Tools >> Migrate DB to export the database. Use the Site 2 url and file location in the Replace fields, and under Advanced Options make sure Replace GUID is unchecked. Export the database.

8. Delete all the tables in the Site 2 database (don't delete the database itself). Import the exported database file from Site 1 to the empty Site 2 database. I used phpMyAdmin.

9. In site 2, open the page with the view. The images will no longer show in "Thumbnail" size. They will show in full size.

10. Repeat steps 7-9, but this time make sure in step 7 that the Replace GUID field is checked. The images at Site 2 will now show correctly in "Thumbnail Size".

Please let me know if you can replicate this problem.

Thanks.

#361684
Screenshot (9).png

Hi all,

I also have this problem when I try to set custom size on like this:

[types field="image" width="300" height="300" align="center"][/types]

As for replicating the problem. This should be very easy, really, as you already have this problem on one of your Showcase site (https://toolset.com/site/turbobike-trainer/).

The error itself, when debuged correctly, it states: 'Destination dir not writable'. But this is really curious, since everything else is working (upload/remove). Only resizing of images is throwing this error.

Project setup on "Bedrock | WordPress Boilerplate | Roots" and Classifieds reference site.

Regards,
Jordan

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.