New answers tagged

1

I don't think there is any all-in-one solution if theme or plugin uses not resized images. They can reach for source images or even access directly without WordPress functions. So, the only way to truly force this kind of themes/plugins is to edit they source files. Which is known as bad practice. But there are some plugins that can reduce this ...


0

The reason for the media uploader not opening when clicking the second button is that both of your buttons have the same ID, which you are also binding to the function that open your uploader. Element IDs should always be unique, hence the .click function listener will only detect when user clicks the first button (=first one with id="image-url"). To solve ...


0

For the sake of "cross-referencing", see my related answer here on StackOverflow about media upload and using that media as "featured media" for a post.


0

The solution is actually very simple, it's just one line of code, since i realized that attachment id is actually same as any other post id i can retrieve user id based on post field. $post_author_id = get_post_field( 'post_author', $post_id ); This gets the user id of the user who uploaded image and $post_id is image attachment id So further checking ...


0

If you check the documentation for media_sideload_image() it returns HTML img tag for the image right away. Alternately it can return just the URL. Note that while this is suitable for immediate use, it's generally challenging to go back from URL to attachment ID. IDs are much more friendly for many things, such as being stored, processed, used to access ...


0

I am using something similar in my website, to only show media attachements uploaded by other users, if this is an option for you, you can use the code or you can edit it to match your need but the truth is that it gets the user ID in the same way it would get it from a post with post_author Here's the code you can test it and see if this will work good for ...


1

I assume you need to show the image url to the user, for all sizes, within the Attachment Details screen. Using Underscore/Backbone We can extend the Attachment Details View, in a similar fashion as in my previous answer here and based on the media views in the core: <!-- Custom template part --> <script type="text/html" id="tmpl-wpse-url-per-...


0

If I understand your question correctly, you would set a your preferred featured image/thumbnail dimensions either in Settings or, if you have or need a new special image type, by adding it to your functions PHP - something like: add_image_size( 'product_preview', 55, 55, true ) ; In order to retroactively crop the old images, pretty much standard practice ...


2

Embarrassing. $(mediaUploader).on('select', function(){ Should be: mediaUploader.on('select', function(){ In case anybody stumbles upon this, $({item}) looks for the item in the DOM, not the variable of the same name in the previous code. Since the select event isn't firing in the DOM, the callback function isn't going to fire either.


1

As Rarst has explained, you can't really directly edit your database, or you'll risk killing the serialized data. Your options are thus to: delete the file and re-upload it with its new name (obviously has the downside of having to reinsert it everywhere it was being used), or to use one of the media renaming / replacing plugins, which through one method ...


1

WP stores considerable amount of attachment data in post meta and serialized form. Raw data looks something like this: _wp_attached_file 2016/04/golden-ragnaros.jpg _wp_attachment_metadata a:5:{s:5:"width";i:488;s:6:"height";i:744;s:4:"file";s:27:"2016/04/golden-ragnaros.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:27:"golden-ragnaros-...


1

I think you should use: get_template_part() So the only thing you have to do is put the get_template_part inside the header.php and add where you want to load it. get_template_part( 'slider' );


2

WordPress has some standard images thumbnail,medium,medium_large,large for which image sizes you can set it under Settings --> Media except medium_large size whose default height set to 768px ( medium_large is available from WP4.4). So when you set 0 to in the media settings it won't generate thumbnail,medium size,large size images and it didn't as far ...



Top 50 recent answers are included