I have this set up with feeds and when importing fields I get the following errors.

Notice: Undefined property: stdClass::$nid in feeds_tokens() (line 32 of /sites/all/modules/feeds/feeds.tokens.inc).

Notice: Undefined index: title in imagefield_tokens_field_attach_presave() (line 203 of /sites/all/modules/imagefield_tokens/imagefield_tokens.module).

The alt field in enabled along with "Update every edit" and "Hide field" while using the node title token as the default value.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

13rac1’s picture

Priority: Normal » Minor

The first notice comes from Feed Tokens. Have you installed this patch or the current dev? #1817992: Notice: Undefined property: stdClass::$nid in feeds_tokens() (line 32 of feeds/feeds.tokens.inc)

Once Feeds Tokens doesn't have a problem, do you still get the notice from ImageField Tokens? We could add an additional test in their for the existence of 'title'.

Setting to Minor for PHP Notice.

walker2238’s picture

Hey thanks for the quick response and helpful information.

I applied the patch and the issue still remains for imagefield tokens. Same error as before.

Notice: Undefined index: title in imagefield_tokens_field_attach_presave() (line 203 of /sites/all/modules/imagefield_tokens/imagefield_tokens.module).

walker2238’s picture

I should also mention that the alt tag remains blank when using a default image, but I guess that could be a separate issue.

walker2238’s picture

Title: Incompatible with Feeds module? » PHP Notice: Undefined index with imagefield tokens while importing feeds.
ressa’s picture

I am getting lots of these in my log files as well, but it all seems to be working fine nevertheless:

Notice: Undefined index: title in imagefield_tokens_field_attach_presave() (line 203 of /srv/www/website/public_html/sites/all/modules/imagefield_tokens/imagefield_tokens.module).

hwasem’s picture

Issue summary: View changes

I agree with ressa. I just installed this module to populate the alt field on my feeds imported images. I am replacing the alt field with the [node:title]. This seems like such a simple thing to accomplish, but I've had much trouble doing it. I am so hopeful I can get this module to help.

I have Feeds 7.x-2.0-alpha8 (4/26/13). Just to be sure, I confirmed the code form the patch listed in #1 above is included. The entire error is

Notice: Undefined index: title in imagefield_tokens_field_attach_presave() (line 203 of /sites/all/modules/imagefield_tokens/imagefield_tokens.module).

I'm using ImageField Tokens 7.x-1.x-dev (2013-Sep-30).

The alt field appears to be populating correctly (Alt="Cover image for [node:title]"), but there is an error for every node I'm importing with Feeds. I'm not using the image's title attribute and don't have that enabled in my field attributes, so I found it odd "title" was the undefined index. I changed the token to be something other than title, but that did not change the error I received. So I don't know why is undefined.

UPDATE:
For testing, I enabled the image's title field and set its default value to [node:title]. Boom, error goes away and module works as configured.

I don't have a problem with having the title of the image be the node title, so this solution works for me, I guess. Hope it helps someone else.

Thanks,
Heidi

mibfire’s picture

millionleaves’s picture

I encountered a version of this issue when I embedded an image in a field collection using the Media Browser. The patch in #7 stopped the error occurring - thanks.

However, I have the ALT text set to populate automatically using tokens. This bit isn't working - seems the tokens I've inserted into the default ALT text field aren't being rendered.

More specifically, I have two tokens like this:

[node-title] - [node:field-collection-field]

When I view the alt text on an image it is set to:

" - "

In other words, the spaces and dash between the tokens are being rendered, but not the token values themselves. I don't know whether the problem lies with the Imagefield Token module or the Media Browser, but the fact that part of my default ALT text value is being rendered suggests it is probably the former.

I tried a different default ALT Text value to use just node fields rather than a field from within the field collection, but the outcome was the same.

nickonom’s picture

#7 worked for me, thanks and rtbc!

generalconsensus’s picture

Status: Active » Needs review

Please patch 7.x, #7 works as suggested

interdruper’s picture

Status: Needs review » Reviewed & tested by the community

#7 tested, rtbc.

Anybody’s picture

Thank you very much, also confirming RTBC. Is there any active maintainer? The notices are appearing in all our projects an fill up watchdog. It would be very helpful to have a new module release containing the fix.

millionleaves’s picture

I've just encountered another issue with this module whereby ALT or TITLE tags that are set to use tokens will not correctly interpret characters such as apostrophes. The patch at this location fixes *that* issue but will not apply if you've applied the patch from #7 in *this* issue.

https://www.drupal.org/node/926966#comment-7564797

The patch to fix special characters in tokens is only a couple of new lines, so if you're going to apply both, you're probably better off applying the patch in #7 from here first and then manually adding the two new lines from the other patch.

I guess a new patch that merges the two would probably make sense (plus updating the other issue to be a duplicate of this one). Happy to post such a patch if required.

(EDIT: updated with link to the patch in the other issue)

NWOM’s picture

#7 works great. Thank you!

ysamoylenko’s picture

Issue tags: +epam-contrib-2019.03

  • ysamoylenko committed db3d417 on 7.x-1.x authored by mibfire
    Issue #1889772 by mibfire, walker2238, millionleaves, Anybody, hwasem,...
ysamoylenko’s picture

Status: Reviewed & tested by the community » Fixed

The patch was committed.

ram4nd’s picture

Issue tags: -epam-contrib-2019.03

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.