Im seeing the following message within Reports when I attempt to use the image_style_url function on an image : "Unable to generate the derived image located at public://..."
I have ensured that the directory is under Apache's ownership and I have no problems attaching images for upload to other nodes.
The style name "template" has been set up within the "Image Styles" menu in the Drupal Administration panel.
When the function is called, an image URL is being returned but the image is not displaying because the image is not being created by the server.
Does anyone have any ideas as to how I can fix this issue?
I am simply printing image_style_url, where "thumbnail" is a name given to the image style that was created in the admin area.
$img_url = $node->field_image[0]['uri'];
print image_style_url("thumbnail", $img_url);
I just had had this problem generating sites/default/files/styles/newsletter_thumbnail/public/Scotland_bankers_2.jpg - it turned out that the file Scotland_bankers_2.jpg didn't exist in the /files/ folder so there was nothing to generate!
The $img_url your passing may be invalid. Check if uri value is accessible.
Do you have multiple images in one field?
I think you should be accessing the data like this:
$node->field_image[$node->language][0]['uri']
I encountered the same error before when my image was deleted.
did u set a style for that image ?
this is how to print the img from a custom template
$style='full_content_width';
$path=$node->my_img_field['und']['0']['uri'];
$style_url = image_style_url($style, $path);
print "<img src=".file_create_url($style_url)." >";
Related
I want to display the preview thumbnail of the multifile upload field. I had followed this thread but I found that {fileName} had some random string. It’s between {input id} and {file.target_name}.
Ex: 4a017277_input_5_zfKuGrwCd91CyiHy_o_1esroacel59uais19ev1dqa405q.png.
What is {zfKuGrwCd91CyiHy}?
tmp image's name
I had found a solution for this. It's not a beautiful way but it worked like a champ.
The random string above was rendered by a function random_str(). My solution is to remove or customizing the function.
File located at path: ../wp-content/plugins/gravityforms/includes/upload.php
enter image description here
I'm using Gravity Forms on a WooCommerce site and I'm trying to allow some additional image types to be uploaded (.tif, .eps, etc.).
I'm completely confused as to why it's not working.
If you try to upload a non-allowed file extension, you get the following error:
"The uploaded file type is not allowed. Must be one of the following: jpg, jpeg, png, gif"
I've search through every Gravity Form file and found two references regarding image uploads. The first in form_display.php which prints the error based on "allowedExtensions".
$field["validation_message"] = empty($field["errorMessage"]) ? sprintf(__("The uploaded file type is not allowed. Must be one of the following: %s", "gravityforms"), strtolower($field["allowedExtensions"]) ) : $field["errorMessage"];
Next, is the allowedExtensions snippet found in js.php
field.label = "<?php _e("Post Image", "gravityforms"); ?>";
field.inputs = null;
field["allowedExtensions"] = "jpg, jpeg, png, gif";
However, changing any of those does nothing. It still prints the same error even if you delete any of them or try to add any file types.
I'm guessing it has to be pulling the allowedExtensions from somewhere else outside of Gravity Forms...
Any ideas?
Gravity Forms doesn't allow additional image filetypes such as EPS and TIFF to be added to the image upload form because these cannot be rendered as thumbnails without installing some sort of server-side component to convert the TIFF etc. to a format which can be displayed by a browser, i.e. JPEG, PNG or GIF.
You'll either have the non-trivial task of installing such a component and modifying the Gravity Forms module to handle these formats; or you could use the standard file upload form field and forgo the thumbnail display.
You can add additional filetypes trough GravityForms itself when you edit the field under "Advanced".
I am using the WPAlchemy class to create a meta box for my custom post type which includes image upload fields. The setup works and I can add image and save the images url for each post. I setup everything as shown here: http://www.farinspace.com/wpalchemy-metabox/#installsetup
How do I now display the saved image meta url on my page? Ideally I would like to be able to display as an image on the page by adding the image's url to image src so it displays the image not the link. However I would be happy to just display the url on the page to start to make sure it's present. But I am really stuck knowing how to echo or print the info to the page. I have tried following some of their examples but nothing seems to be working and I sometimes get php errors saying:
Fatal error: Call to a member function the_name() on a non-object in C:\
Any help appreciated. I thought it would be easier than it is, like the_meta() or something similar but it's not clear what to add to get the info showing up on page.
Cheers
Best things to do is use:
global $custom_mb;
$meta = $custom_mb->the_meta([ID_IS_OPTIONAL]);
$meta will be an array of all your stored values for the given post, loop through it as you normally would loop an array
I have several custom content types and in one specific one I need to offer two fields, one for the href for a link, and one for the text of a link this way I can build and style it with minimal user involvement of the HTML/CSS. I also have a custom node.tpl for this content type. My problem is that drupal throws divs around each field I create that aren't in my template file for this content type (node-custom.tpl) and I can't put the href for a link with divs around it inside google.co.uk</div>"> See my problem. Maybe I'm doing this all wrong so any other ideas are welcome.
Please note I'm trying to create this site with minimum involvement of HTML/CSS access for the user. I'm aware I could hand code the link in the field.
The easiest way to do this would be to use a preprocess function in your template.php file and build the link up manually:
function mytheme_preprocess_node(&$vars) {
$node = $vars['node'];
if ($node->type = 'my_type') {
$uri = $node->field_name_of_link_field[LANGUAGE_NONE][0]['value'];
$text = $node->field_name_of_display_text_field[LANGUAGE_NONE][0]['value'];
$vars['my_link'] = l($text, $uri); // Using Drupal's l() function to render a link
}
}
Then in your node template file you'll have access to the variable $my_link which you can output anywhere, and will contain the correct HTML for the link. Finally, go to the "Manage Display" page for your content type and set the display of the two fields you no longer need to output to 'Hidden'.
There are other ways so if that's no good let me know
EDIT
Just to add, I think the easiest way to do this would actually be to install the Link module and use the provided field type instead of the two other fields you're currently using.
how do I grab images from a node using php? I"m using views_get_view_result to retrieve the array from Views and for the image field I get a serialized string:
a:2:{s:3:"alt";s:20:"south pacific poster";s:5:"title";s:0:"";}
it contains no reference as to where the image is located or the name of the image. In Views the image displays properly in the preview area.
Thanks
ah! Views has an option for URL to File
Its hard to tell exactly what you are doing, but you can get the filepath from the fid with something like:
<?php
$r = db_result(db_query('select filepath from files where fid=%d',$fid));